diff --git a/api/models/b_g_p_apply_policy_to_neighbor_mod.go b/api/models/b_g_p_apply_policy_to_neighbor_mod.go new file mode 100644 index 000000000..43999f9ef --- /dev/null +++ b/api/models/b_g_p_apply_policy_to_neighbor_mod.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPApplyPolicyToNeighborMod b g p apply policy to neighbor mod +// +// swagger:model BGPApplyPolicyToNeighborMod +type BGPApplyPolicyToNeighborMod struct { + + // BGP Neighbor IP address + IPAddress string `json:"ipAddress,omitempty"` + + // policies + Policies []string `json:"policies"` + + // policy type + PolicyType string `json:"policyType,omitempty"` + + // route action + RouteAction string `json:"routeAction,omitempty"` +} + +// Validate validates this b g p apply policy to neighbor mod +func (m *BGPApplyPolicyToNeighborMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p apply policy to neighbor mod based on context it is used +func (m *BGPApplyPolicyToNeighborMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPApplyPolicyToNeighborMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPApplyPolicyToNeighborMod) UnmarshalBinary(b []byte) error { + var res BGPApplyPolicyToNeighborMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_a_s_path_mod.go b/api/models/b_g_p_policy_a_s_path_mod.go new file mode 100644 index 000000000..6f54171d6 --- /dev/null +++ b/api/models/b_g_p_policy_a_s_path_mod.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyASPathMod b g p policy a s path mod +// +// swagger:model BGPPolicyASPathMod +type BGPPolicyASPathMod struct { + + // as path list + AsPathList []string `json:"asPathList"` + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy a s path mod +func (m *BGPPolicyASPathMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy a s path mod based on context it is used +func (m *BGPPolicyASPathMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyASPathMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyASPathMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyASPathMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_community_mod.go b/api/models/b_g_p_policy_community_mod.go new file mode 100644 index 000000000..e8d7976df --- /dev/null +++ b/api/models/b_g_p_policy_community_mod.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyCommunityMod b g p policy community mod +// +// swagger:model BGPPolicyCommunityMod +type BGPPolicyCommunityMod struct { + + // community list + CommunityList []string `json:"communityList"` + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy community mod +func (m *BGPPolicyCommunityMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy community mod based on context it is used +func (m *BGPPolicyCommunityMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyCommunityMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyCommunityMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyCommunityMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_defind_set_mod.go b/api/models/b_g_p_policy_defind_set_mod.go new file mode 100644 index 000000000..7191b733f --- /dev/null +++ b/api/models/b_g_p_policy_defind_set_mod.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefindSetMod b g p policy defind set mod +// +// swagger:model BGPPolicyDefindSetMod +type BGPPolicyDefindSetMod struct { + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` + + // statements + Statements []*BGPPolicyDefindSetStatement `json:"statements"` +} + +// Validate validates this b g p policy defind set mod +func (m *BGPPolicyDefindSetMod) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatements(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetMod) validateStatements(formats strfmt.Registry) error { + if swag.IsZero(m.Statements) { // not required + return nil + } + + for i := 0; i < len(m.Statements); i++ { + if swag.IsZero(m.Statements[i]) { // not required + continue + } + + if m.Statements[i] != nil { + if err := m.Statements[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("statements" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("statements" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this b g p policy defind set mod based on the context it is used +func (m *BGPPolicyDefindSetMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateStatements(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetMod) contextValidateStatements(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Statements); i++ { + + if m.Statements[i] != nil { + if err := m.Statements[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("statements" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("statements" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_defind_set_statement.go b/api/models/b_g_p_policy_defind_set_statement.go new file mode 100644 index 000000000..82a44a4c2 --- /dev/null +++ b/api/models/b_g_p_policy_defind_set_statement.go @@ -0,0 +1,1391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefindSetStatement b g p policy defind set statement +// +// swagger:model BGPPolicyDefindSetStatement +type BGPPolicyDefindSetStatement struct { + + // actions + Actions *BGPPolicyDefindSetStatementActions `json:"actions,omitempty"` + + // conditions + Conditions *BGPPolicyDefindSetStatementConditions `json:"conditions,omitempty"` + + // name + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy defind set statement +func (m *BGPPolicyDefindSetStatement) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConditions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatement) validateActions(formats strfmt.Registry) error { + if swag.IsZero(m.Actions) { // not required + return nil + } + + if m.Actions != nil { + if err := m.Actions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatement) validateConditions(formats strfmt.Registry) error { + if swag.IsZero(m.Conditions) { // not required + return nil + } + + if m.Conditions != nil { + if err := m.Conditions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy defind set statement based on the context it is used +func (m *BGPPolicyDefindSetStatement) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateActions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateConditions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatement) contextValidateActions(ctx context.Context, formats strfmt.Registry) error { + + if m.Actions != nil { + if err := m.Actions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatement) contextValidateConditions(ctx context.Context, formats strfmt.Registry) error { + + if m.Conditions != nil { + if err := m.Conditions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatement) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatement) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatement + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActions b g p policy defind set statement actions +// +// swagger:model BGPPolicyDefindSetStatementActions +type BGPPolicyDefindSetStatementActions struct { + + // bgp actions + BgpActions *BGPPolicyDefindSetStatementActionsBgpActions `json:"bgpActions,omitempty"` + + // route disposition + RouteDisposition string `json:"routeDisposition,omitempty"` +} + +// Validate validates this b g p policy defind set statement actions +func (m *BGPPolicyDefindSetStatementActions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBgpActions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementActions) validateBgpActions(formats strfmt.Registry) error { + if swag.IsZero(m.BgpActions) { // not required + return nil + } + + if m.BgpActions != nil { + if err := m.BgpActions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy defind set statement actions based on the context it is used +func (m *BGPPolicyDefindSetStatementActions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBgpActions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementActions) contextValidateBgpActions(ctx context.Context, formats strfmt.Registry) error { + + if m.BgpActions != nil { + if err := m.BgpActions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActionsBgpActions b g p policy defind set statement actions bgp actions +// +// swagger:model BGPPolicyDefindSetStatementActionsBgpActions +type BGPPolicyDefindSetStatementActionsBgpActions struct { + + // set as path prepend + SetAsPathPrepend *BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend `json:"setAsPathPrepend,omitempty"` + + // set community + SetCommunity *BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity `json:"setCommunity,omitempty"` + + // set ext community + SetExtCommunity *BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity `json:"setExtCommunity,omitempty"` + + // set large community + SetLargeCommunity *BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity `json:"setLargeCommunity,omitempty"` + + // set local perf + SetLocalPerf int64 `json:"setLocalPerf,omitempty"` + + // set med + SetMed string `json:"setMed,omitempty"` + + // set next hop + SetNextHop string `json:"setNextHop,omitempty"` +} + +// Validate validates this b g p policy defind set statement actions bgp actions +func (m *BGPPolicyDefindSetStatementActionsBgpActions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSetAsPathPrepend(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetCommunity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetExtCommunity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetLargeCommunity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) validateSetAsPathPrepend(formats strfmt.Registry) error { + if swag.IsZero(m.SetAsPathPrepend) { // not required + return nil + } + + if m.SetAsPathPrepend != nil { + if err := m.SetAsPathPrepend.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) validateSetCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetCommunity) { // not required + return nil + } + + if m.SetCommunity != nil { + if err := m.SetCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) validateSetExtCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetExtCommunity) { // not required + return nil + } + + if m.SetExtCommunity != nil { + if err := m.SetExtCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) validateSetLargeCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetLargeCommunity) { // not required + return nil + } + + if m.SetLargeCommunity != nil { + if err := m.SetLargeCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy defind set statement actions bgp actions based on the context it is used +func (m *BGPPolicyDefindSetStatementActionsBgpActions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSetAsPathPrepend(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetExtCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetLargeCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) contextValidateSetAsPathPrepend(ctx context.Context, formats strfmt.Registry) error { + + if m.SetAsPathPrepend != nil { + if err := m.SetAsPathPrepend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) contextValidateSetCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetCommunity != nil { + if err := m.SetCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) contextValidateSetExtCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetExtCommunity != nil { + if err := m.SetExtCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementActionsBgpActions) contextValidateSetLargeCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetLargeCommunity != nil { + if err := m.SetLargeCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActionsBgpActions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend b g p policy defind set statement actions bgp actions set as path prepend +// +// swagger:model BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend +type BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend struct { + + // as + As string `json:"as,omitempty"` + + // repeat n + RepeatN int64 `json:"repeatN,omitempty"` +} + +// Validate validates this b g p policy defind set statement actions bgp actions set as path prepend +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement actions bgp actions set as path prepend based on context it is used +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActionsBgpActionsSetAsPathPrepend + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity b g p policy defind set statement actions bgp actions set community +// +// swagger:model BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity +type BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy defind set statement actions bgp actions set community +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement actions bgp actions set community based on context it is used +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActionsBgpActionsSetCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity b g p policy defind set statement actions bgp actions set ext community +// +// swagger:model BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity +type BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy defind set statement actions bgp actions set ext community +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement actions bgp actions set ext community based on context it is used +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActionsBgpActionsSetExtCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity b g p policy defind set statement actions bgp actions set large community +// +// swagger:model BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity +type BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy defind set statement actions bgp actions set large community +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement actions bgp actions set large community based on context it is used +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementActionsBgpActionsSetLargeCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditions b g p policy defind set statement conditions +// +// swagger:model BGPPolicyDefindSetStatementConditions +type BGPPolicyDefindSetStatementConditions struct { + + // bgp conditions + BgpConditions *BGPPolicyDefindSetStatementConditionsBgpConditions `json:"bgpConditions,omitempty"` + + // match neighbor set + MatchNeighborSet *BGPPolicyDefindSetStatementConditionsMatchNeighborSet `json:"matchNeighborSet,omitempty"` + + // match prefix set + MatchPrefixSet *BGPPolicyDefindSetStatementConditionsMatchPrefixSet `json:"matchPrefixSet,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions +func (m *BGPPolicyDefindSetStatementConditions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBgpConditions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchNeighborSet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchPrefixSet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) validateBgpConditions(formats strfmt.Registry) error { + if swag.IsZero(m.BgpConditions) { // not required + return nil + } + + if m.BgpConditions != nil { + if err := m.BgpConditions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) validateMatchNeighborSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchNeighborSet) { // not required + return nil + } + + if m.MatchNeighborSet != nil { + if err := m.MatchNeighborSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchNeighborSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchNeighborSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) validateMatchPrefixSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchPrefixSet) { // not required + return nil + } + + if m.MatchPrefixSet != nil { + if err := m.MatchPrefixSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchPrefixSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchPrefixSet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy defind set statement conditions based on the context it is used +func (m *BGPPolicyDefindSetStatementConditions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBgpConditions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchNeighborSet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchPrefixSet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) contextValidateBgpConditions(ctx context.Context, formats strfmt.Registry) error { + + if m.BgpConditions != nil { + if err := m.BgpConditions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) contextValidateMatchNeighborSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchNeighborSet != nil { + if err := m.MatchNeighborSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchNeighborSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchNeighborSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditions) contextValidateMatchPrefixSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchPrefixSet != nil { + if err := m.MatchPrefixSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchPrefixSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchPrefixSet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditions b g p policy defind set statement conditions bgp conditions +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditions +type BGPPolicyDefindSetStatementConditionsBgpConditions struct { + + // afi safi in + AfiSafiIn []string `json:"afiSafiIn"` + + // as path length + AsPathLength *BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength `json:"asPathLength,omitempty"` + + // match as path set + MatchAsPathSet *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet `json:"matchAsPathSet,omitempty"` + + // match community set + MatchCommunitySet *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet `json:"matchCommunitySet,omitempty"` + + // match ext community set + MatchExtCommunitySet *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet `json:"matchExtCommunitySet,omitempty"` + + // match large community set + MatchLargeCommunitySet *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet `json:"matchLargeCommunitySet,omitempty"` + + // next hop in list + NextHopInList []string `json:"nextHopInList"` + + // route type + RouteType string `json:"routeType,omitempty"` + + // rpki + Rpki string `json:"rpki,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAsPathLength(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchAsPathSet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchCommunitySet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchExtCommunitySet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchLargeCommunitySet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) validateAsPathLength(formats strfmt.Registry) error { + if swag.IsZero(m.AsPathLength) { // not required + return nil + } + + if m.AsPathLength != nil { + if err := m.AsPathLength.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) validateMatchAsPathSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchAsPathSet) { // not required + return nil + } + + if m.MatchAsPathSet != nil { + if err := m.MatchAsPathSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) validateMatchCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchCommunitySet) { // not required + return nil + } + + if m.MatchCommunitySet != nil { + if err := m.MatchCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) validateMatchExtCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchExtCommunitySet) { // not required + return nil + } + + if m.MatchExtCommunitySet != nil { + if err := m.MatchExtCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) validateMatchLargeCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchLargeCommunitySet) { // not required + return nil + } + + if m.MatchLargeCommunitySet != nil { + if err := m.MatchLargeCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy defind set statement conditions bgp conditions based on the context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAsPathLength(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchAsPathSet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchExtCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchLargeCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) contextValidateAsPathLength(ctx context.Context, formats strfmt.Registry) error { + + if m.AsPathLength != nil { + if err := m.AsPathLength.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) contextValidateMatchAsPathSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchAsPathSet != nil { + if err := m.MatchAsPathSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) contextValidateMatchCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchCommunitySet != nil { + if err := m.MatchCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) contextValidateMatchExtCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchExtCommunitySet != nil { + if err := m.MatchExtCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) contextValidateMatchLargeCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchLargeCommunitySet != nil { + if err := m.MatchLargeCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength b g p policy defind set statement conditions bgp conditions as path length +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength +type BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength struct { + + // operator + Operator string `json:"operator,omitempty"` + + // value + Value int64 `json:"value,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions as path length +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions bgp conditions as path length based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditionsAsPathLength + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet b g p policy defind set statement conditions bgp conditions match as path set +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet +type BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet struct { + + // as path set + AsPathSet string `json:"asPathSet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions match as path set +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions bgp conditions match as path set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditionsMatchAsPathSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet b g p policy defind set statement conditions bgp conditions match community set +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet +type BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions match community set +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions bgp conditions match community set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditionsMatchCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet b g p policy defind set statement conditions bgp conditions match ext community set +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet +type BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions match ext community set +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions bgp conditions match ext community set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditionsMatchExtCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet b g p policy defind set statement conditions bgp conditions match large community set +// +// swagger:model BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet +type BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions bgp conditions match large community set +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions bgp conditions match large community set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsBgpConditionsMatchLargeCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsMatchNeighborSet b g p policy defind set statement conditions match neighbor set +// +// swagger:model BGPPolicyDefindSetStatementConditionsMatchNeighborSet +type BGPPolicyDefindSetStatementConditionsMatchNeighborSet struct { + + // match set option + MatchSetOption string `json:"matchSetOption,omitempty"` + + // neighbor set + NeighborSet string `json:"neighborSet,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions match neighbor set +func (m *BGPPolicyDefindSetStatementConditionsMatchNeighborSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions match neighbor set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsMatchNeighborSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsMatchNeighborSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsMatchNeighborSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsMatchNeighborSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefindSetStatementConditionsMatchPrefixSet b g p policy defind set statement conditions match prefix set +// +// swagger:model BGPPolicyDefindSetStatementConditionsMatchPrefixSet +type BGPPolicyDefindSetStatementConditionsMatchPrefixSet struct { + + // match set option + MatchSetOption string `json:"matchSetOption,omitempty"` + + // prefix set + PrefixSet string `json:"prefixSet,omitempty"` +} + +// Validate validates this b g p policy defind set statement conditions match prefix set +func (m *BGPPolicyDefindSetStatementConditionsMatchPrefixSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy defind set statement conditions match prefix set based on context it is used +func (m *BGPPolicyDefindSetStatementConditionsMatchPrefixSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsMatchPrefixSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefindSetStatementConditionsMatchPrefixSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefindSetStatementConditionsMatchPrefixSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_defined_set_get_entry.go b/api/models/b_g_p_policy_defined_set_get_entry.go new file mode 100644 index 000000000..d5673fa83 --- /dev/null +++ b/api/models/b_g_p_policy_defined_set_get_entry.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefinedSetGetEntry b g p policy defined set get entry +// +// swagger:model BGPPolicyDefinedSetGetEntry +type BGPPolicyDefinedSetGetEntry struct { + + // list + List []string `json:"list"` + + // BGP Defined set Entries + Name string `json:"name,omitempty"` + + // prefix list + PrefixList []*BGPPolicyPrefix `json:"prefixList"` +} + +// Validate validates this b g p policy defined set get entry +func (m *BGPPolicyDefinedSetGetEntry) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePrefixList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinedSetGetEntry) validatePrefixList(formats strfmt.Registry) error { + if swag.IsZero(m.PrefixList) { // not required + return nil + } + + for i := 0; i < len(m.PrefixList); i++ { + if swag.IsZero(m.PrefixList[i]) { // not required + continue + } + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this b g p policy defined set get entry based on the context it is used +func (m *BGPPolicyDefinedSetGetEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePrefixList(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinedSetGetEntry) contextValidatePrefixList(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PrefixList); i++ { + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinedSetGetEntry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinedSetGetEntry) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinedSetGetEntry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_defined_sets_mod.go b/api/models/b_g_p_policy_defined_sets_mod.go new file mode 100644 index 000000000..8769b6962 --- /dev/null +++ b/api/models/b_g_p_policy_defined_sets_mod.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefinedSetsMod b g p policy defined sets mod +// +// swagger:model BGPPolicyDefinedSetsMod +type BGPPolicyDefinedSetsMod struct { + + // list + List []string `json:"List"` + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` + + // prefix list + PrefixList []*BGPPolicyPrefix `json:"prefixList"` +} + +// Validate validates this b g p policy defined sets mod +func (m *BGPPolicyDefinedSetsMod) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePrefixList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinedSetsMod) validatePrefixList(formats strfmt.Registry) error { + if swag.IsZero(m.PrefixList) { // not required + return nil + } + + for i := 0; i < len(m.PrefixList); i++ { + if swag.IsZero(m.PrefixList[i]) { // not required + continue + } + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this b g p policy defined sets mod based on the context it is used +func (m *BGPPolicyDefinedSetsMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePrefixList(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinedSetsMod) contextValidatePrefixList(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PrefixList); i++ { + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinedSetsMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinedSetsMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinedSetsMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_definitions_mod.go b/api/models/b_g_p_policy_definitions_mod.go new file mode 100644 index 000000000..e49dd0506 --- /dev/null +++ b/api/models/b_g_p_policy_definitions_mod.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefinitionsMod b g p policy definitions mod +// +// swagger:model BGPPolicyDefinitionsMod +type BGPPolicyDefinitionsMod struct { + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` + + // statements + Statements []*BGPPolicyDefinitionsStatement `json:"statements"` +} + +// Validate validates this b g p policy definitions mod +func (m *BGPPolicyDefinitionsMod) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatements(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsMod) validateStatements(formats strfmt.Registry) error { + if swag.IsZero(m.Statements) { // not required + return nil + } + + for i := 0; i < len(m.Statements); i++ { + if swag.IsZero(m.Statements[i]) { // not required + continue + } + + if m.Statements[i] != nil { + if err := m.Statements[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("statements" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("statements" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this b g p policy definitions mod based on the context it is used +func (m *BGPPolicyDefinitionsMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateStatements(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsMod) contextValidateStatements(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Statements); i++ { + + if m.Statements[i] != nil { + if err := m.Statements[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("statements" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("statements" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_definitions_statement.go b/api/models/b_g_p_policy_definitions_statement.go new file mode 100644 index 000000000..81d5cb40f --- /dev/null +++ b/api/models/b_g_p_policy_definitions_statement.go @@ -0,0 +1,1391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyDefinitionsStatement b g p policy definitions statement +// +// swagger:model BGPPolicyDefinitionsStatement +type BGPPolicyDefinitionsStatement struct { + + // actions + Actions *BGPPolicyDefinitionsStatementActions `json:"actions,omitempty"` + + // conditions + Conditions *BGPPolicyDefinitionsStatementConditions `json:"conditions,omitempty"` + + // name + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy definitions statement +func (m *BGPPolicyDefinitionsStatement) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConditions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatement) validateActions(formats strfmt.Registry) error { + if swag.IsZero(m.Actions) { // not required + return nil + } + + if m.Actions != nil { + if err := m.Actions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatement) validateConditions(formats strfmt.Registry) error { + if swag.IsZero(m.Conditions) { // not required + return nil + } + + if m.Conditions != nil { + if err := m.Conditions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy definitions statement based on the context it is used +func (m *BGPPolicyDefinitionsStatement) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateActions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateConditions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatement) contextValidateActions(ctx context.Context, formats strfmt.Registry) error { + + if m.Actions != nil { + if err := m.Actions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatement) contextValidateConditions(ctx context.Context, formats strfmt.Registry) error { + + if m.Conditions != nil { + if err := m.Conditions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatement) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatement) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatement + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActions b g p policy definitions statement actions +// +// swagger:model BGPPolicyDefinitionsStatementActions +type BGPPolicyDefinitionsStatementActions struct { + + // bgp actions + BgpActions *BGPPolicyDefinitionsStatementActionsBgpActions `json:"bgpActions,omitempty"` + + // route disposition + RouteDisposition string `json:"routeDisposition,omitempty"` +} + +// Validate validates this b g p policy definitions statement actions +func (m *BGPPolicyDefinitionsStatementActions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBgpActions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementActions) validateBgpActions(formats strfmt.Registry) error { + if swag.IsZero(m.BgpActions) { // not required + return nil + } + + if m.BgpActions != nil { + if err := m.BgpActions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy definitions statement actions based on the context it is used +func (m *BGPPolicyDefinitionsStatementActions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBgpActions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementActions) contextValidateBgpActions(ctx context.Context, formats strfmt.Registry) error { + + if m.BgpActions != nil { + if err := m.BgpActions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActionsBgpActions b g p policy definitions statement actions bgp actions +// +// swagger:model BGPPolicyDefinitionsStatementActionsBgpActions +type BGPPolicyDefinitionsStatementActionsBgpActions struct { + + // set as path prepend + SetAsPathPrepend *BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend `json:"setAsPathPrepend,omitempty"` + + // set community + SetCommunity *BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity `json:"setCommunity,omitempty"` + + // set ext community + SetExtCommunity *BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity `json:"setExtCommunity,omitempty"` + + // set large community + SetLargeCommunity *BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity `json:"setLargeCommunity,omitempty"` + + // set local perf + SetLocalPerf int64 `json:"setLocalPerf,omitempty"` + + // set med + SetMed string `json:"setMed,omitempty"` + + // set next hop + SetNextHop string `json:"setNextHop,omitempty"` +} + +// Validate validates this b g p policy definitions statement actions bgp actions +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSetAsPathPrepend(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetCommunity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetExtCommunity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSetLargeCommunity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) validateSetAsPathPrepend(formats strfmt.Registry) error { + if swag.IsZero(m.SetAsPathPrepend) { // not required + return nil + } + + if m.SetAsPathPrepend != nil { + if err := m.SetAsPathPrepend.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) validateSetCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetCommunity) { // not required + return nil + } + + if m.SetCommunity != nil { + if err := m.SetCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) validateSetExtCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetExtCommunity) { // not required + return nil + } + + if m.SetExtCommunity != nil { + if err := m.SetExtCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) validateSetLargeCommunity(formats strfmt.Registry) error { + if swag.IsZero(m.SetLargeCommunity) { // not required + return nil + } + + if m.SetLargeCommunity != nil { + if err := m.SetLargeCommunity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy definitions statement actions bgp actions based on the context it is used +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSetAsPathPrepend(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetExtCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSetLargeCommunity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) contextValidateSetAsPathPrepend(ctx context.Context, formats strfmt.Registry) error { + + if m.SetAsPathPrepend != nil { + if err := m.SetAsPathPrepend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setAsPathPrepend") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) contextValidateSetCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetCommunity != nil { + if err := m.SetCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) contextValidateSetExtCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetExtCommunity != nil { + if err := m.SetExtCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setExtCommunity") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) contextValidateSetLargeCommunity(ctx context.Context, formats strfmt.Registry) error { + + if m.SetLargeCommunity != nil { + if err := m.SetLargeCommunity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("actions" + "." + "bgpActions" + "." + "setLargeCommunity") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActionsBgpActions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend b g p policy definitions statement actions bgp actions set as path prepend +// +// swagger:model BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend +type BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend struct { + + // as + As string `json:"as,omitempty"` + + // repeat n + RepeatN int64 `json:"repeatN,omitempty"` +} + +// Validate validates this b g p policy definitions statement actions bgp actions set as path prepend +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement actions bgp actions set as path prepend based on context it is used +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity b g p policy definitions statement actions bgp actions set community +// +// swagger:model BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity +type BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy definitions statement actions bgp actions set community +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement actions bgp actions set community based on context it is used +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity b g p policy definitions statement actions bgp actions set ext community +// +// swagger:model BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity +type BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy definitions statement actions bgp actions set ext community +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement actions bgp actions set ext community based on context it is used +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity b g p policy definitions statement actions bgp actions set large community +// +// swagger:model BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity +type BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity struct { + + // options + Options string `json:"options,omitempty"` + + // set community method + SetCommunityMethod []string `json:"setCommunityMethod"` +} + +// Validate validates this b g p policy definitions statement actions bgp actions set large community +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement actions bgp actions set large community based on context it is used +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditions b g p policy definitions statement conditions +// +// swagger:model BGPPolicyDefinitionsStatementConditions +type BGPPolicyDefinitionsStatementConditions struct { + + // bgp conditions + BgpConditions *BGPPolicyDefinitionsStatementConditionsBgpConditions `json:"bgpConditions,omitempty"` + + // match neighbor set + MatchNeighborSet *BGPPolicyDefinitionsStatementConditionsMatchNeighborSet `json:"matchNeighborSet,omitempty"` + + // match prefix set + MatchPrefixSet *BGPPolicyDefinitionsStatementConditionsMatchPrefixSet `json:"matchPrefixSet,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions +func (m *BGPPolicyDefinitionsStatementConditions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBgpConditions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchNeighborSet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchPrefixSet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) validateBgpConditions(formats strfmt.Registry) error { + if swag.IsZero(m.BgpConditions) { // not required + return nil + } + + if m.BgpConditions != nil { + if err := m.BgpConditions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) validateMatchNeighborSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchNeighborSet) { // not required + return nil + } + + if m.MatchNeighborSet != nil { + if err := m.MatchNeighborSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchNeighborSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchNeighborSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) validateMatchPrefixSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchPrefixSet) { // not required + return nil + } + + if m.MatchPrefixSet != nil { + if err := m.MatchPrefixSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchPrefixSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchPrefixSet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy definitions statement conditions based on the context it is used +func (m *BGPPolicyDefinitionsStatementConditions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBgpConditions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchNeighborSet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchPrefixSet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) contextValidateBgpConditions(ctx context.Context, formats strfmt.Registry) error { + + if m.BgpConditions != nil { + if err := m.BgpConditions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) contextValidateMatchNeighborSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchNeighborSet != nil { + if err := m.MatchNeighborSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchNeighborSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchNeighborSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditions) contextValidateMatchPrefixSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchPrefixSet != nil { + if err := m.MatchPrefixSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "matchPrefixSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "matchPrefixSet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditions b g p policy definitions statement conditions bgp conditions +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditions +type BGPPolicyDefinitionsStatementConditionsBgpConditions struct { + + // afi safi in + AfiSafiIn []string `json:"afiSafiIn"` + + // as path length + AsPathLength *BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength `json:"asPathLength,omitempty"` + + // match as path set + MatchAsPathSet *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet `json:"matchAsPathSet,omitempty"` + + // match community set + MatchCommunitySet *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet `json:"matchCommunitySet,omitempty"` + + // match ext community set + MatchExtCommunitySet *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet `json:"matchExtCommunitySet,omitempty"` + + // match large community set + MatchLargeCommunitySet *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet `json:"matchLargeCommunitySet,omitempty"` + + // next hop in list + NextHopInList []string `json:"nextHopInList"` + + // route type + RouteType string `json:"routeType,omitempty"` + + // rpki + Rpki string `json:"rpki,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAsPathLength(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchAsPathSet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchCommunitySet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchExtCommunitySet(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchLargeCommunitySet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) validateAsPathLength(formats strfmt.Registry) error { + if swag.IsZero(m.AsPathLength) { // not required + return nil + } + + if m.AsPathLength != nil { + if err := m.AsPathLength.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) validateMatchAsPathSet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchAsPathSet) { // not required + return nil + } + + if m.MatchAsPathSet != nil { + if err := m.MatchAsPathSet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) validateMatchCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchCommunitySet) { // not required + return nil + } + + if m.MatchCommunitySet != nil { + if err := m.MatchCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) validateMatchExtCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchExtCommunitySet) { // not required + return nil + } + + if m.MatchExtCommunitySet != nil { + if err := m.MatchExtCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) validateMatchLargeCommunitySet(formats strfmt.Registry) error { + if swag.IsZero(m.MatchLargeCommunitySet) { // not required + return nil + } + + if m.MatchLargeCommunitySet != nil { + if err := m.MatchLargeCommunitySet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this b g p policy definitions statement conditions bgp conditions based on the context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAsPathLength(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchAsPathSet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchExtCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMatchLargeCommunitySet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) contextValidateAsPathLength(ctx context.Context, formats strfmt.Registry) error { + + if m.AsPathLength != nil { + if err := m.AsPathLength.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "asPathLength") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) contextValidateMatchAsPathSet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchAsPathSet != nil { + if err := m.MatchAsPathSet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchAsPathSet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) contextValidateMatchCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchCommunitySet != nil { + if err := m.MatchCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) contextValidateMatchExtCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchExtCommunitySet != nil { + if err := m.MatchExtCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchExtCommunitySet") + } + return err + } + } + + return nil +} + +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) contextValidateMatchLargeCommunitySet(ctx context.Context, formats strfmt.Registry) error { + + if m.MatchLargeCommunitySet != nil { + if err := m.MatchLargeCommunitySet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + "bgpConditions" + "." + "matchLargeCommunitySet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditions) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength b g p policy definitions statement conditions bgp conditions as path length +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength +type BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength struct { + + // operator + Operator string `json:"operator,omitempty"` + + // value + Value int64 `json:"value,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions as path length +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions bgp conditions as path length based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet b g p policy definitions statement conditions bgp conditions match as path set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet +type BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet struct { + + // as path set + AsPathSet string `json:"asPathSet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions match as path set +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions bgp conditions match as path set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet b g p policy definitions statement conditions bgp conditions match community set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet +type BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions match community set +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions bgp conditions match community set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet b g p policy definitions statement conditions bgp conditions match ext community set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet +type BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions match ext community set +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions bgp conditions match ext community set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet b g p policy definitions statement conditions bgp conditions match large community set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet +type BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet struct { + + // community set + CommunitySet string `json:"communitySet,omitempty"` + + // match set options + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions bgp conditions match large community set +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions bgp conditions match large community set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsMatchNeighborSet b g p policy definitions statement conditions match neighbor set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsMatchNeighborSet +type BGPPolicyDefinitionsStatementConditionsMatchNeighborSet struct { + + // match set option + MatchSetOption string `json:"matchSetOption,omitempty"` + + // neighbor set + NeighborSet string `json:"neighborSet,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions match neighbor set +func (m *BGPPolicyDefinitionsStatementConditionsMatchNeighborSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions match neighbor set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsMatchNeighborSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsMatchNeighborSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsMatchNeighborSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsMatchNeighborSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// BGPPolicyDefinitionsStatementConditionsMatchPrefixSet b g p policy definitions statement conditions match prefix set +// +// swagger:model BGPPolicyDefinitionsStatementConditionsMatchPrefixSet +type BGPPolicyDefinitionsStatementConditionsMatchPrefixSet struct { + + // match set option + MatchSetOption string `json:"matchSetOption,omitempty"` + + // prefix set + PrefixSet string `json:"prefixSet,omitempty"` +} + +// Validate validates this b g p policy definitions statement conditions match prefix set +func (m *BGPPolicyDefinitionsStatementConditionsMatchPrefixSet) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy definitions statement conditions match prefix set based on context it is used +func (m *BGPPolicyDefinitionsStatementConditionsMatchPrefixSet) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsMatchPrefixSet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyDefinitionsStatementConditionsMatchPrefixSet) UnmarshalBinary(b []byte) error { + var res BGPPolicyDefinitionsStatementConditionsMatchPrefixSet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_extended_community_mod.go b/api/models/b_g_p_policy_extended_community_mod.go new file mode 100644 index 000000000..8ac4a67ae --- /dev/null +++ b/api/models/b_g_p_policy_extended_community_mod.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyExtendedCommunityMod b g p policy extended community mod +// +// swagger:model BGPPolicyExtendedCommunityMod +type BGPPolicyExtendedCommunityMod struct { + + // ext community list + ExtCommunityList []string `json:"extCommunityList"` + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy extended community mod +func (m *BGPPolicyExtendedCommunityMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy extended community mod based on context it is used +func (m *BGPPolicyExtendedCommunityMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyExtendedCommunityMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyExtendedCommunityMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyExtendedCommunityMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_large_community_mod.go b/api/models/b_g_p_policy_large_community_mod.go new file mode 100644 index 000000000..7261eea23 --- /dev/null +++ b/api/models/b_g_p_policy_large_community_mod.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyLargeCommunityMod b g p policy large community mod +// +// swagger:model BGPPolicyLargeCommunityMod +type BGPPolicyLargeCommunityMod struct { + + // large community list + LargeCommunityList []string `json:"LargeCommunityList"` + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` +} + +// Validate validates this b g p policy large community mod +func (m *BGPPolicyLargeCommunityMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy large community mod based on context it is used +func (m *BGPPolicyLargeCommunityMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyLargeCommunityMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyLargeCommunityMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyLargeCommunityMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_neighbor_mod.go b/api/models/b_g_p_policy_neighbor_mod.go new file mode 100644 index 000000000..3e7c5f188 --- /dev/null +++ b/api/models/b_g_p_policy_neighbor_mod.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyNeighborMod b g p policy neighbor mod +// +// swagger:model BGPPolicyNeighborMod +type BGPPolicyNeighborMod struct { + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` + + // neighbor info list + NeighborInfoList []string `json:"neighborInfoList"` +} + +// Validate validates this b g p policy neighbor mod +func (m *BGPPolicyNeighborMod) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy neighbor mod based on context it is used +func (m *BGPPolicyNeighborMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyNeighborMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyNeighborMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyNeighborMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_prefix.go b/api/models/b_g_p_policy_prefix.go new file mode 100644 index 000000000..25932db1c --- /dev/null +++ b/api/models/b_g_p_policy_prefix.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyPrefix b g p policy prefix +// +// swagger:model BGPPolicyPrefix +type BGPPolicyPrefix struct { + + // BGP Neighbor IP address + IPPrefix string `json:"ipPrefix,omitempty"` + + // Remote AS number + MasklengthRange string `json:"masklengthRange,omitempty"` +} + +// Validate validates this b g p policy prefix +func (m *BGPPolicyPrefix) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this b g p policy prefix based on context it is used +func (m *BGPPolicyPrefix) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyPrefix) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyPrefix) UnmarshalBinary(b []byte) error { + var res BGPPolicyPrefix + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/b_g_p_policy_prefix_mod.go b/api/models/b_g_p_policy_prefix_mod.go new file mode 100644 index 000000000..f782bfb07 --- /dev/null +++ b/api/models/b_g_p_policy_prefix_mod.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BGPPolicyPrefixMod b g p policy prefix mod +// +// swagger:model BGPPolicyPrefixMod +type BGPPolicyPrefixMod struct { + + // BGP Neighbor IP address + Name string `json:"name,omitempty"` + + // prefix list + PrefixList []*BGPPolicyPrefix `json:"prefixList"` +} + +// Validate validates this b g p policy prefix mod +func (m *BGPPolicyPrefixMod) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePrefixList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyPrefixMod) validatePrefixList(formats strfmt.Registry) error { + if swag.IsZero(m.PrefixList) { // not required + return nil + } + + for i := 0; i < len(m.PrefixList); i++ { + if swag.IsZero(m.PrefixList[i]) { // not required + continue + } + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this b g p policy prefix mod based on the context it is used +func (m *BGPPolicyPrefixMod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePrefixList(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BGPPolicyPrefixMod) contextValidatePrefixList(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PrefixList); i++ { + + if m.PrefixList[i] != nil { + if err := m.PrefixList[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prefixList" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BGPPolicyPrefixMod) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BGPPolicyPrefixMod) UnmarshalBinary(b []byte) error { + var res BGPPolicyPrefixMod + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/restapi/configure_loxilb_rest_api.go b/api/restapi/configure_loxilb_rest_api.go index b8547f823..7f5f15112 100644 --- a/api/restapi/configure_loxilb_rest_api.go +++ b/api/restapi/configure_loxilb_rest_api.go @@ -163,6 +163,18 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler { api.PostConfigBgpNeighHandler = operations.PostConfigBgpNeighHandlerFunc(handler.ConfigPostBGPNeigh) api.DeleteConfigBgpNeighIPAddressHandler = operations.DeleteConfigBgpNeighIPAddressHandlerFunc(handler.ConfigDeleteBGPNeigh) + // BGP Policy Defined set + api.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler = operations.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc(handler.ConfigGetBGPPolicyDefinedSetGet) + api.PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler = operations.PostConfigBgpPolicyDefinedsetsDefinesetTypeHandlerFunc(handler.ConfigPostBGPPolicyDefinedsets) + api.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler = operations.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc(handler.ConfigDeleteBGPPolicyDefinedsets) + + // BGP Policy Definitions + api.PostConfigBgpPolicyDefinitionsHandler = operations.PostConfigBgpPolicyDefinitionsHandlerFunc(handler.ConfigPostBGPPolicyDefinitions) + api.DeleteConfigBgpPolicyDefinitionsPolicyNameHandler = operations.DeleteConfigBgpPolicyDefinitionsPolicyNameHandlerFunc(handler.ConfigDeleteBGPPolicyDefinitions) + api.GetConfigBgpPolicyDefinitionsAllHandler = operations.GetConfigBgpPolicyDefinitionsAllHandlerFunc(handler.ConfigGetBGPPolicyDefinitions) + + // BGP Policy Apply + api.PostConfigBgpPolicyApplyHandler = operations.PostConfigBgpPolicyApplyHandlerFunc(handler.ConfigPostBGPPolicyApply) api.PreServerShutdown = func() {} api.ServerShutdown = func() {} diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 8839a0211..045bf62b7 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -473,18 +473,18 @@ func init() { } } }, - "/config/cistate": { + "/config/bgp/policy/apply": { "post": { - "description": "Informs Current Cluster Instance state in the device", - "summary": "Informs Current Cluster Instance state in the device", + "description": "Apply BGP Policy in neighbor", + "summary": "Apply BGP Policy in neighbor", "parameters": [ { - "description": "Attributes for CI State", + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/CIStatusEntry" + "$ref": "#/definitions/BGPApplyPolicyToNeighborMod" } } ], @@ -537,98 +537,25 @@ func init() { } } }, - "/config/cistate/all": { - "get": { - "description": "Get Cluster Instance State in the device", - "summary": "Get Cluster Instance State in the device", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "Attr": { - "type": "array", - "items": { - "$ref": "#/definitions/CIStatusGetEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/conntrack/all": { - "get": { - "description": "Get all of the conntrack infomation for all of the service.", - "summary": "Get all of the conntrack entries.", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "ctAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/ConntrackEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/endpoint": { + "/config/bgp/policy/definedsets/{defineset_type}": { "post": { - "description": "Adds a LB endpoint for monitoring", - "summary": "Adds a LB endpoint for monitoring", + "description": "Adds a BGP definedsets for making Policy", + "summary": "Adds a BGP definedsets for making Policy", "parameters": [ { - "description": "Attributes of end point", + "type": "string", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", + "in": "path", + "required": true + }, + { + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/EndPoint" + "$ref": "#/definitions/BGPPolicyDefinedSetsMod" } } ], @@ -681,31 +608,74 @@ func init() { } } }, - "/config/endpoint/all": { + "/config/bgp/policy/definedsets/{defineset_type}/{type_name}": { "get": { - "description": "Get End-Points State in loxilb", - "summary": "Get End-Points State in loxilb", + "description": "Get the all of BGP, prefix/neighbor/community/extcommunity/aspath/largecommunity", + "summary": "Get the all of BGP definedsets", + "parameters": [ + { + "type": "string", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "type name", + "name": "type_name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "Attr": { + "definedsetsAttr": { "type": "array", "items": { - "$ref": "#/definitions/EndPointGetEntry" + "$ref": "#/definitions/BGPPolicyDefinedSetGetEntry" } } } } }, + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -719,37 +689,24 @@ func init() { } } } - } - }, - "/config/endpoint/epipaddress/{ip_address}": { + }, "delete": { - "description": "Delete an LB end-point from monitoring", - "summary": "Delete an LB end-point from monitoring", + "description": "Delete a BGP definedsets", + "summary": "Delete a BGP definedsets", "parameters": [ { "type": "string", - "description": "Attributes of end point", - "name": "ip_address", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", "in": "path", "required": true }, { "type": "string", - "description": "Endpoint Identifier", - "name": "name", - "in": "query" - }, - { - "type": "string", - "description": "Probe type", - "name": "probe_type", - "in": "query" - }, - { - "type": "number", - "description": "Probe port", - "name": "probe_port", - "in": "query" + "description": "type name", + "name": "type_name", + "in": "path", + "required": true } ], "responses": { @@ -781,7 +738,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. Neigh already exists", "schema": { "$ref": "#/definitions/Error" } @@ -801,18 +758,18 @@ func init() { } } }, - "/config/fdb": { + "/config/bgp/policy/definitions": { "post": { - "description": "Assign FDB in the device", - "summary": "Assign FDB in the device", + "description": "Adds a BGP Policy", + "summary": "Adds a BGP Policy", "parameters": [ { - "description": "Attributes for IPv4 address", + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/FDBEntry" + "$ref": "#/definitions/BGPPolicyDefinitionsMod" } } ], @@ -845,7 +802,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -865,20 +822,20 @@ func init() { } } }, - "/config/fdb/all": { + "/config/bgp/policy/definitions/all": { "get": { - "description": "Get FDB in the device(interface).", - "summary": "Get FDB in the device(interface)", + "description": "Get BGP Policy definitions", + "summary": "Get BGP Policy definitions", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "fdbAttr": { + "bgpPolicyAttr": { "type": "array", "items": { - "$ref": "#/definitions/FDBEntry" + "$ref": "#/definitions/BGPPolicyDefinitionsMod" } } } @@ -905,22 +862,15 @@ func init() { } } }, - "/config/fdb/{mac_address}/dev/{if_name}": { + "/config/bgp/policy/definitions/{policy_name}": { "delete": { - "description": "Delete FDB in the device", - "summary": "Delete FDB in the device", + "description": "Delete a BGP Policy", + "summary": "Delete a BGP policy", "parameters": [ { "type": "string", - "description": "Attributes IPv4 Address in the device", - "name": "mac_address", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Attributes of the target device", - "name": "if_name", + "description": "The name of the community", + "name": "policy_name", "in": "path", "required": true } @@ -954,7 +904,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. Neigh already exists", "schema": { "$ref": "#/definitions/Error" } @@ -974,18 +924,18 @@ func init() { } } }, - "/config/firewall": { + "/config/cistate": { "post": { - "description": "Create a new firewall config for security.", - "summary": "Create a new firewall config", + "description": "Informs Current Cluster Instance state in the device", + "summary": "Informs Current Cluster Instance state in the device", "parameters": [ { - "description": "Attributes for firewall sevice", + "description": "Attributes for CI State", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/FirewallEntry" + "$ref": "#/definitions/CIStatusEntry" } } ], @@ -1018,7 +968,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -1036,99 +986,32 @@ func init() { } } } - }, - "delete": { - "description": "Delete of the firewall service.", - "summary": "Delete of the firewall service", - "parameters": [ - { - "type": "string", - "description": "Source IP address", - "name": "sourceIP", - "in": "query" - }, - { - "type": "string", - "description": "Destination IP in CIDR notation", - "name": "destinationIP", - "in": "query" + } + }, + "/config/cistate/all": { + "get": { + "description": "Get Cluster Instance State in the device", + "summary": "Get Cluster Instance State in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "Attr": { + "type": "array", + "items": { + "$ref": "#/definitions/CIStatusGetEntry" + } + } + } + } }, - { - "type": "integer", - "description": "Minimum source port range", - "name": "minSourcePort", - "in": "query" - }, - { - "type": "integer", - "description": "Maximum source port range", - "name": "maxSourcePort", - "in": "query" - }, - { - "type": "integer", - "description": "Minimum destination port range", - "name": "minDestinationPort", - "in": "query" - }, - { - "type": "integer", - "description": "Maximum destination port range", - "name": "maxDestinationPort", - "in": "query" - }, - { - "type": "integer", - "description": "the protocol", - "name": "protocol", - "in": "query" - }, - { - "type": "string", - "description": "the incoming port", - "name": "portName", - "in": "query" - }, - { - "type": "integer", - "description": "User preference for ordering", - "name": "preference", - "in": "query" - } - ], - "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } }, "500": { "description": "Internal service error", @@ -1145,20 +1028,20 @@ func init() { } } }, - "/config/firewall/all": { + "/config/conntrack/all": { "get": { - "description": "Get all of the firewall configuration.", - "summary": "Get all of the firewall config", + "description": "Get all of the conntrack infomation for all of the service.", + "summary": "Get all of the conntrack entries.", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "fwAttr": { + "ctAttr": { "type": "array", "items": { - "$ref": "#/definitions/FirewallEntry" + "$ref": "#/definitions/ConntrackEntry" } } } @@ -1185,18 +1068,18 @@ func init() { } } }, - "/config/ipv4address": { + "/config/endpoint": { "post": { - "description": "Assign IPv4 addresses in the device", - "summary": "Assign IPv4 addresses in the device", + "description": "Adds a LB endpoint for monitoring", + "summary": "Adds a LB endpoint for monitoring", "parameters": [ { - "description": "Attributes for IPv4 address", + "description": "Attributes of end point", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/IPv4AddressEntry" + "$ref": "#/definitions/EndPoint" } } ], @@ -1229,7 +1112,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -1249,20 +1132,20 @@ func init() { } } }, - "/config/ipv4address/all": { + "/config/endpoint/all": { "get": { - "description": "Get IPv4 addresses in the device(interface)", - "summary": "Get IPv4 addresses in the device(interface)", + "description": "Get End-Points State in loxilb", + "summary": "Get End-Points State in loxilb", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "ipAttr": { + "Attr": { "type": "array", "items": { - "$ref": "#/definitions/IPv4AddressGetEntry" + "$ref": "#/definitions/EndPointGetEntry" } } } @@ -1289,31 +1172,35 @@ func init() { } } }, - "/config/ipv4address/{ip_address}/{mask}/dev/{if_name}": { + "/config/endpoint/epipaddress/{ip_address}": { "delete": { - "description": "Delete IPv4 addresses in the device", - "summary": "Delete IPv4 addresses in the device", + "description": "Delete an LB end-point from monitoring", + "summary": "Delete an LB end-point from monitoring", "parameters": [ { "type": "string", - "description": "Attributes IPv4 Address in the device", + "description": "Attributes of end point", "name": "ip_address", "in": "path", "required": true }, { "type": "string", - "description": "Attributes IPv4 mask in the device", - "name": "mask", - "in": "path", - "required": true + "description": "Endpoint Identifier", + "name": "name", + "in": "query" }, { "type": "string", - "description": "Attributes of the target device", - "name": "if_name", - "in": "path", - "required": true + "description": "Probe type", + "name": "probe_type", + "in": "query" + }, + { + "type": "number", + "description": "Probe port", + "name": "probe_port", + "in": "query" } ], "responses": { @@ -1365,27 +1252,24 @@ func init() { } } }, - "/config/loadbalancer": { + "/config/fdb": { "post": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", + "description": "Assign FDB in the device", + "summary": "Assign FDB in the device", "parameters": [ { - "description": "Attributes for load balance service", + "description": "Attributes for IPv4 address", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/LoadbalanceEntry" + "$ref": "#/definitions/FDBEntry" } } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/PostSuccess" - } + "204": { + "description": "OK" }, "400": { "description": "Malformed arguments for API call", @@ -1432,20 +1316,20 @@ func init() { } } }, - "/config/loadbalancer/all": { + "/config/fdb/all": { "get": { - "description": "Get all of the load balancer services with conntrack infomation.", - "summary": "Get all of the load balancer services", + "description": "Get FDB in the device(interface).", + "summary": "Get FDB in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "lbAttr": { + "fdbAttr": { "type": "array", "items": { - "$ref": "#/definitions/LoadbalanceEntry" + "$ref": "#/definitions/FDBEntry" } } } @@ -1470,96 +1354,26 @@ func init() { } } } - }, - "delete": { - "description": "Delete all load balancer services.", - "summary": "Delete all Load balancer services", - "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } } }, - "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "/config/fdb/{mac_address}/dev/{if_name}": { "delete": { - "description": "Delete an existing load balancer service with .", - "summary": "Delete an existing Load balancer service", + "description": "Delete FDB in the device", + "summary": "Delete FDB in the device", "parameters": [ { "type": "string", - "description": "Attributes for load balance service", - "name": "ip_address", - "in": "path", - "required": true - }, - { - "type": "number", - "description": "Attributes for load balance service", - "name": "port", + "description": "Attributes IPv4 Address in the device", + "name": "mac_address", "in": "path", "required": true }, { "type": "string", - "description": "Attributes for load balance service", - "name": "proto", + "description": "Attributes of the target device", + "name": "if_name", "in": "path", "required": true - }, - { - "type": "boolean", - "description": "option for BGP enable", - "name": "bgp", - "in": "query" - }, - { - "type": "number", - "description": "block value if any", - "name": "block", - "in": "query" } ], "responses": { @@ -1611,18 +1425,18 @@ func init() { } } }, - "/config/mirror": { + "/config/firewall": { "post": { - "description": "Create a new Mirror config.", - "summary": "Create a new Mirror config", + "description": "Create a new firewall config for security.", + "summary": "Create a new firewall config", "parameters": [ { - "description": "Attributes for Mirror", + "description": "Attributes for firewall sevice", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/MirrorEntry" + "$ref": "#/definitions/FirewallEntry" } } ], @@ -1673,59 +1487,64 @@ func init() { } } } - } - }, - "/config/mirror/all": { - "get": { - "description": "Get", - "summary": "Get", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "mirrAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/MirrorGetEntry" - } - } - } - } + }, + "delete": { + "description": "Delete of the firewall service.", + "summary": "Delete of the firewall service", + "parameters": [ + { + "type": "string", + "description": "Source IP address", + "name": "sourceIP", + "in": "query" }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } + { + "type": "string", + "description": "Destination IP in CIDR notation", + "name": "destinationIP", + "in": "query" }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } + { + "type": "integer", + "description": "Minimum source port range", + "name": "minSourcePort", + "in": "query" + }, + { + "type": "integer", + "description": "Maximum source port range", + "name": "maxSourcePort", + "in": "query" + }, + { + "type": "integer", + "description": "Minimum destination port range", + "name": "minDestinationPort", + "in": "query" + }, + { + "type": "integer", + "description": "Maximum destination port range", + "name": "maxDestinationPort", + "in": "query" + }, + { + "type": "integer", + "description": "the protocol", + "name": "protocol", + "in": "query" }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/mirror/ident/{ident}": { - "delete": { - "description": "Delete a new Create a Mirror service.", - "summary": "Delete a Mirror service", - "parameters": [ { "type": "string", - "description": "Attributes of Mirror Ident.", - "name": "ident", - "in": "path", - "required": true + "description": "the incoming port", + "name": "portName", + "in": "query" + }, + { + "type": "integer", + "description": "User preference for ordering", + "name": "preference", + "in": "query" } ], "responses": { @@ -1777,10 +1596,50 @@ func init() { } } }, - "/config/neighbor": { + "/config/firewall/all": { + "get": { + "description": "Get all of the firewall configuration.", + "summary": "Get all of the firewall config", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "fwAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/FirewallEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/ipv4address": { "post": { - "description": "Assign IPv4 neighbor in the device", - "summary": "Assign IPv4 neighbor in the device", + "description": "Assign IPv4 addresses in the device", + "summary": "Assign IPv4 addresses in the device", "parameters": [ { "description": "Attributes for IPv4 address", @@ -1788,7 +1647,7 @@ func init() { "in": "body", "required": true, "schema": { - "$ref": "#/definitions/NeighborEntry" + "$ref": "#/definitions/IPv4AddressEntry" } } ], @@ -1841,20 +1700,20 @@ func init() { } } }, - "/config/neighbor/all": { + "/config/ipv4address/all": { "get": { - "description": "Get IPv4 neighbor in the device(interface)", - "summary": "Get IPv4 neighbor in the device(interface)", + "description": "Get IPv4 addresses in the device(interface)", + "summary": "Get IPv4 addresses in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "neighborAttr": { + "ipAttr": { "type": "array", "items": { - "$ref": "#/definitions/NeighborEntry" + "$ref": "#/definitions/IPv4AddressGetEntry" } } } @@ -1881,10 +1740,10 @@ func init() { } } }, - "/config/neighbor/{ip_address}/dev/{if_name}": { + "/config/ipv4address/{ip_address}/{mask}/dev/{if_name}": { "delete": { - "description": "Delete IPv4 neighbor in the device", - "summary": "Delete IPv4 neighbor in the device", + "description": "Delete IPv4 addresses in the device", + "summary": "Delete IPv4 addresses in the device", "parameters": [ { "type": "string", @@ -1893,6 +1752,13 @@ func init() { "in": "path", "required": true }, + { + "type": "string", + "description": "Attributes IPv4 mask in the device", + "name": "mask", + "in": "path", + "required": true + }, { "type": "string", "description": "Attributes of the target device", @@ -1950,20 +1816,28 @@ func init() { } } }, - "/config/params": { - "get": { - "description": "Get Operational params of LoxiLB", - "summary": "Get Operational params of LoxiLB", + "/config/loadbalancer": { + "post": { + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", + "parameters": [ + { + "description": "Attributes for load balance service", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/LoadbalanceEntry" + } + } + ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/OperParams" + "$ref": "#/definitions/PostSuccess" } }, - "204": { - "description": "OK" - }, "400": { "description": "Malformed arguments for API call", "schema": { @@ -2007,21 +1881,50 @@ func init() { } } } - }, - "post": { - "description": "Set Operational parameters of LoxiLB", - "summary": "Set Operational parameters of LoxiLB", - "parameters": [ - { - "description": "Attributes for setting state", - "name": "attr", - "in": "body", - "required": true, + } + }, + "/config/loadbalancer/all": { + "get": { + "description": "Get all of the load balancer services with conntrack infomation.", + "summary": "Get all of the load balancer services", + "responses": { + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/OperParams" + "type": "object", + "properties": { + "lbAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/LoadbalanceEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" } } - ], + } + }, + "delete": { + "description": "Delete all load balancer services.", + "summary": "Delete all Load balancer services", "responses": { "204": { "description": "OK" @@ -2071,18 +1974,106 @@ func init() { } } }, - "/config/policy": { - "post": { - "description": "Create a new Policy QoS config.", - "summary": "Create a new Policy QoS config", + "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "delete": { + "description": "Delete an existing load balancer service with .", + "summary": "Delete an existing Load balancer service", "parameters": [ { - "description": "Attributes for Policy", - "name": "attr", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/PolicyEntry" + "type": "string", + "description": "Attributes for load balance service", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "number", + "description": "Attributes for load balance service", + "name": "port", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for load balance service", + "name": "proto", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "option for BGP enable", + "name": "bgp", + "in": "query" + }, + { + "type": "number", + "description": "block value if any", + "name": "block", + "in": "query" + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/mirror": { + "post": { + "description": "Create a new Mirror config.", + "summary": "Create a new Mirror config", + "parameters": [ + { + "description": "Attributes for Mirror", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/MirrorEntry" } } ], @@ -2135,7 +2126,7 @@ func init() { } } }, - "/config/policy/all": { + "/config/mirror/all": { "get": { "description": "Get", "summary": "Get", @@ -2145,10 +2136,10 @@ func init() { "schema": { "type": "object", "properties": { - "polAttr": { + "mirrAttr": { "type": "array", "items": { - "$ref": "#/definitions/PolicyEntry" + "$ref": "#/definitions/MirrorGetEntry" } } } @@ -2175,14 +2166,14 @@ func init() { } } }, - "/config/policy/ident/{ident}": { + "/config/mirror/ident/{ident}": { "delete": { - "description": "Delete a new Create a Policy QoS service.", - "summary": "Delete a Policy QoS service", + "description": "Delete a new Create a Mirror service.", + "summary": "Delete a Mirror service", "parameters": [ { "type": "string", - "description": "Attributes of Policy Ident.", + "description": "Attributes of Mirror Ident.", "name": "ident", "in": "path", "required": true @@ -2237,58 +2228,18 @@ func init() { } } }, - "/config/port/all": { - "get": { - "description": "Get all of the port interfaces.", - "summary": "Get all of the port interfaces", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "portAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/PortEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/route": { + "/config/neighbor": { "post": { - "description": "Create a new route config .", - "summary": "Create a new route config", + "description": "Assign IPv4 neighbor in the device", + "summary": "Assign IPv4 neighbor in the device", "parameters": [ { - "description": "Attributes for load balance service", + "description": "Attributes for IPv4 address", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/RouteEntry" + "$ref": "#/definitions/NeighborEntry" } } ], @@ -2341,25 +2292,70 @@ func init() { } } }, - "/config/route/all": { + "/config/neighbor/all": { "get": { - "description": "Get all route table", - "summary": "Get all route table", + "description": "Get IPv4 neighbor in the device(interface)", + "summary": "Get IPv4 neighbor in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "routeAttr": { + "neighborAttr": { "type": "array", "items": { - "$ref": "#/definitions/RouteGetEntry" + "$ref": "#/definitions/NeighborEntry" } } } } }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/neighbor/{ip_address}/dev/{if_name}": { + "delete": { + "description": "Delete IPv4 neighbor in the device", + "summary": "Delete IPv4 neighbor in the device", + "parameters": [ + { + "type": "string", + "description": "Attributes IPv4 Address in the device", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes of the target device", + "name": "if_name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "OK" + }, "400": { "description": "Malformed arguments for API call", "schema": { @@ -2405,27 +2401,17 @@ func init() { } } }, - "/config/route/destinationIPNet/{ip_address}/{mask}": { - "delete": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", - "parameters": [ - { - "type": "string", - "description": "Attributes for destinaion route address", - "name": "ip_address", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Attributes for destination route", - "name": "mask", - "in": "path", - "required": true - } - ], + "/config/params": { + "get": { + "description": "Get Operational params of LoxiLB", + "summary": "Get Operational params of LoxiLB", "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/OperParams" + } + }, "204": { "description": "OK" }, @@ -2472,20 +2458,18 @@ func init() { } } } - } - }, - "/config/session": { + }, "post": { - "description": "Create a new session config for 5G.", - "summary": "Create a new session config", + "description": "Set Operational parameters of LoxiLB", + "summary": "Set Operational parameters of LoxiLB", "parameters": [ { - "description": "Attributes for 5G service session", + "description": "Attributes for setting state", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/SessionEntry" + "$ref": "#/definitions/OperParams" } } ], @@ -2538,20 +2522,84 @@ func init() { } } }, - "/config/session/all": { + "/config/policy": { + "post": { + "description": "Create a new Policy QoS config.", + "summary": "Create a new Policy QoS config", + "parameters": [ + { + "description": "Attributes for Policy", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PolicyEntry" + } + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/policy/all": { "get": { - "description": "Get all of the port interfaces.", - "summary": "Get all of the port interfaces", + "description": "Get", + "summary": "Get", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "sessionAttr": { + "polAttr": { "type": "array", "items": { - "$ref": "#/definitions/SessionEntry" + "$ref": "#/definitions/PolicyEntry" } } } @@ -2578,14 +2626,14 @@ func init() { } } }, - "/config/session/ident/{ident}": { + "/config/policy/ident/{ident}": { "delete": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", + "description": "Delete a new Create a Policy QoS service.", + "summary": "Delete a Policy QoS service", "parameters": [ { "type": "string", - "description": "Attributes 5G session Ident.", + "description": "Attributes of Policy Ident.", "name": "ident", "in": "path", "required": true @@ -2640,18 +2688,58 @@ func init() { } } }, - "/config/sessionulcl": { + "/config/port/all": { + "get": { + "description": "Get all of the port interfaces.", + "summary": "Get all of the port interfaces", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "portAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/PortEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/route": { "post": { - "description": "Create a new session config for 5G.", - "summary": "Create a new session config", + "description": "Create a new route config .", + "summary": "Create a new route config", "parameters": [ { - "description": "Attributes for 5G service session", + "description": "Attributes for load balance service", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/SessionUlClEntry" + "$ref": "#/definitions/RouteEntry" } } ], @@ -2704,31 +2792,55 @@ func init() { } } }, - "/config/sessionulcl/all": { + "/config/route/all": { "get": { - "description": "Get", - "summary": "Get", + "description": "Get all route table", + "summary": "Get all route table", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "ulclAttr": { + "routeAttr": { "type": "array", "items": { - "$ref": "#/definitions/SessionUlClEntry" + "$ref": "#/definitions/RouteGetEntry" } } } } }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -2744,22 +2856,22 @@ func init() { } } }, - "/config/sessionulcl/ident/{ident}/ulclAddress/{ip_address}": { + "/config/route/destinationIPNet/{ip_address}/{mask}": { "delete": { "description": "Create a new load balancer service with .", "summary": "Create a new Load balancer service", "parameters": [ { "type": "string", - "description": "Attributes 5G session Ident.", - "name": "ident", + "description": "Attributes for destinaion route address", + "name": "ip_address", "in": "path", "required": true }, { - "type": "string", - "description": "Attributes for session ulcl address", - "name": "ip_address", + "type": "integer", + "description": "Attributes for destination route", + "name": "mask", "in": "path", "required": true } @@ -2813,18 +2925,18 @@ func init() { } } }, - "/config/tunnel/vxlan": { + "/config/session": { "post": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Add a one of vxlan configuration", + "description": "Create a new session config for 5G.", + "summary": "Create a new session config", "parameters": [ { - "description": "attributes for vxlan member interface", + "description": "Attributes for 5G service session", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VxlanBridgeEntry" + "$ref": "#/definitions/SessionEntry" } } ], @@ -2832,14 +2944,32 @@ func init() { "204": { "description": "OK" }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "409": { - "description": "Resource Conflict. VxLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", "schema": { "$ref": "#/definitions/Error" } @@ -2859,20 +2989,20 @@ func init() { } } }, - "/config/tunnel/vxlan/all": { + "/config/session/all": { "get": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Get a list of vxlan configurations", + "description": "Get all of the port interfaces.", + "summary": "Get all of the port interfaces", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "vxlanAttr": { + "sessionAttr": { "type": "array", "items": { - "$ref": "#/definitions/VxlanEntry" + "$ref": "#/definitions/SessionEntry" } } } @@ -2899,16 +3029,15 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}": { + "/config/session/ident/{ident}": { "delete": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Delete a one of vxlan configuration", + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", "parameters": [ { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", + "type": "string", + "description": "Attributes 5G session Ident.", + "name": "ident", "in": "path", "required": true } @@ -2917,12 +3046,36 @@ func init() { "204": { "description": "OK" }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -2938,34 +3091,29 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}/peer": { + "/config/sessionulcl": { "post": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Add a one of vxlan remote(peer) ip address configuration", + "description": "Create a new session config for 5G.", + "summary": "Create a new session config", "parameters": [ { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", - "in": "path", - "required": true - }, - { - "description": "attributes for vxlan Peer interface", + "description": "Attributes for 5G service session", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VxlanPeerEntry" + "$ref": "#/definitions/SessionUlClEntry" } } ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "$ref": "#/definitions/VxlanPeerEntry" + "$ref": "#/definitions/Error" } }, "401": { @@ -2974,6 +3122,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -2989,32 +3155,23 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}/peer/{PeerIP}": { - "delete": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Remove a one of vxlan remote(peer) ip address configuration", - "parameters": [ - { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "attributes for vxlan Peer IP address", - "name": "PeerIP", - "in": "path", - "required": true - } - ], + "/config/sessionulcl/all": { + "get": { + "description": "Get", + "summary": "Get", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/VxlanEntry" + "type": "object", + "properties": { + "ulclAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/SessionUlClEntry" + } + } + } } }, "401": { @@ -3038,19 +3195,24 @@ func init() { } } }, - "/config/vlan": { - "post": { - "description": "Create vlan interface in the device", - "summary": "Create vlan interface in the device", + "/config/sessionulcl/ident/{ident}/ulclAddress/{ip_address}": { + "delete": { + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", "parameters": [ { - "description": "Attributes for Vlan Interface", - "name": "attr", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/VlanBridgeEntry" - } + "type": "string", + "description": "Attributes 5G session Ident.", + "name": "ident", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for session ulcl address", + "name": "ip_address", + "in": "path", + "required": true } ], "responses": { @@ -3102,20 +3264,66 @@ func init() { } } }, - "/config/vlan/all": { + "/config/tunnel/vxlan": { + "post": { + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Add a one of vxlan configuration", + "parameters": [ + { + "description": "attributes for vxlan member interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VxlanBridgeEntry" + } + } + ], + "responses": { + "204": { + "description": "OK" + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VxLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/tunnel/vxlan/all": { "get": { - "description": "Get vlan in the device", - "summary": "Get vlan in the device", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Get a list of vxlan configurations", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "vlanAttr": { + "vxlanAttr": { "type": "array", "items": { - "$ref": "#/definitions/VlanGetEntry" + "$ref": "#/definitions/VxlanEntry" } } } @@ -3142,15 +3350,16 @@ func init() { } } }, - "/config/vlan/{vlan_id}": { + "/config/tunnel/vxlan/{vxlanID}": { "delete": { - "description": "Delete vlan in the device", - "summary": "Delete vlan in the device", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Delete a one of vxlan configuration", "parameters": [ { "type": "integer", - "description": "Attributes IPv4 Address in the device", - "name": "vlan_id", + "format": "int32", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true } @@ -3159,36 +3368,12 @@ func init() { "204": { "description": "OK" }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, "500": { "description": "Internal service error", "schema": { @@ -3204,37 +3389,34 @@ func init() { } } }, - "/config/vlan/{vlan_id}/member": { + "/config/tunnel/vxlan/{vxlanID}/peer": { "post": { - "description": "Add a member to interface Vlan{vlan_id}. If the vlan interface does not exist on LoxiLB it returns a '404' error. If such a member is already present on this Vlan interface the API returns '409' sub-code 0. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'. If attr with tagging mode is provided it will be honored in config, if not, the default tagging mode will be set to 'untagged'. Vlan members may be tagged or untagged, but, the Vlan member port may be untagged in only one Vlan interface, deviations from this will cause the API to return '409' sub-code 0.", - "summary": "Add a physical port to a vlan interface", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Add a one of vxlan remote(peer) ip address configuration", "parameters": [ { "type": "integer", "format": "int32", - "description": "12 bit vlan_id", - "name": "vlan_id", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true }, { - "description": "Attributes for Vlan Interface", + "description": "attributes for vxlan Peer interface", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VlanMemberEntry" + "$ref": "#/definitions/VxlanPeerEntry" } } ], "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/Error" + "$ref": "#/definitions/VxlanPeerEntry" } }, "401": { @@ -3243,24 +3425,6 @@ func init() { "$ref": "#/definitions/Error" } }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Vlan interface is not defined", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN member already exists on this VLAN interface OR Vlan member is being added to 2nd Vlan inteface as an untagged member.", - "schema": { - "$ref": "#/definitions/Error" - } - }, "500": { "description": "Internal service error", "schema": { @@ -3276,34 +3440,70 @@ func init() { } } }, - "/config/vlan/{vlan_id}/member/{if_name}/tagged/{tagged}": { + "/config/tunnel/vxlan/{vxlanID}/peer/{PeerIP}": { "delete": { - "description": "Remove a vlan member from a vlan interface which is defined by vlan_id. If the Vlan interface does not exist on LoxiLB OR a vlan member 'if_name' is not present on the interface the API will return '404'. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'.", - "summary": "Remove a vlan member from a vlan interface", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Remove a one of vxlan remote(peer) ip address configuration", "parameters": [ { "type": "integer", "format": "int32", - "description": "12 bit vlan_id", - "name": "vlan_id", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true }, { "type": "string", - "description": "Physical port name", - "name": "if_name", - "in": "path", - "required": true - }, - { - "type": "boolean", - "description": "Tagged status", - "name": "tagged", + "description": "attributes for vxlan Peer IP address", + "name": "PeerIP", "in": "path", "required": true } ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/VxlanEntry" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/vlan": { + "post": { + "description": "Create vlan interface in the device", + "summary": "Create vlan interface in the device", + "parameters": [ + { + "description": "Attributes for Vlan Interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VlanBridgeEntry" + } + } + ], "responses": { "204": { "description": "OK" @@ -3320,8 +3520,20 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, "404": { - "description": "Vlan interface is not defined/Vlan member is not found on this Vlan interface", + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", "schema": { "$ref": "#/definitions/Error" } @@ -3341,28 +3553,67 @@ func init() { } } }, - "/metrics": { + "/config/vlan/all": { "get": { - "summary": "Scrape metrics from the cache", + "description": "Get vlan in the device", + "summary": "Get vlan in the device", "responses": { "200": { - "description": "Metrics in prometheus text format", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "properties": { + "vlanAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/VlanGetEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" } } } } }, - "/status/device": { - "get": { - "description": "Get a basic info (linux command \"uptime, hostnamectl\") in the device or system.", - "summary": "Get a basic info in the device", + "/config/vlan/{vlan_id}": { + "delete": { + "description": "Delete vlan in the device", + "summary": "Delete vlan in the device", + "parameters": [ + { + "type": "integer", + "description": "Attributes IPv4 Address in the device", + "name": "vlan_id", + "in": "path", + "required": true + } + ], "responses": { - "200": { - "description": "Device unique informations", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "$ref": "#/definitions/DeviceInfoEntry" + "$ref": "#/definitions/Error" } }, "401": { @@ -3371,6 +3622,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -3386,23 +3655,37 @@ func init() { } } }, - "/status/filesystem": { - "get": { - "description": "Get a File system infomation (linux command \"df\") in the device or system.", - "summary": "Get a File System info in the device", + "/config/vlan/{vlan_id}/member": { + "post": { + "description": "Add a member to interface Vlan{vlan_id}. If the vlan interface does not exist on LoxiLB it returns a '404' error. If such a member is already present on this Vlan interface the API returns '409' sub-code 0. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'. If attr with tagging mode is provided it will be honored in config, if not, the default tagging mode will be set to 'untagged'. Vlan members may be tagged or untagged, but, the Vlan member port may be untagged in only one Vlan interface, deviations from this will cause the API to return '409' sub-code 0.", + "summary": "Add a physical port to a vlan interface", + "parameters": [ + { + "type": "integer", + "format": "int32", + "description": "12 bit vlan_id", + "name": "vlan_id", + "in": "path", + "required": true + }, + { + "description": "Attributes for Vlan Interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VlanMemberEntry" + } + } + ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "type": "object", - "properties": { - "filesystemAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/FileSystemInfoEntry" - } - } - } + "$ref": "#/definitions/Error" } }, "401": { @@ -3411,6 +3694,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Vlan interface is not defined", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN member already exists on this VLAN interface OR Vlan member is being added to 2nd Vlan inteface as an untagged member.", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -3426,23 +3727,42 @@ func init() { } } }, - "/status/process": { - "get": { - "description": "Get a process based on high usage CPU(linux command \"top\") in the device or system.", - "summary": "Get a process based on CPU usage info in the device", + "/config/vlan/{vlan_id}/member/{if_name}/tagged/{tagged}": { + "delete": { + "description": "Remove a vlan member from a vlan interface which is defined by vlan_id. If the Vlan interface does not exist on LoxiLB OR a vlan member 'if_name' is not present on the interface the API will return '404'. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'.", + "summary": "Remove a vlan member from a vlan interface", + "parameters": [ + { + "type": "integer", + "format": "int32", + "description": "12 bit vlan_id", + "name": "vlan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Physical port name", + "name": "if_name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Tagged status", + "name": "tagged", + "in": "path", + "required": true + } + ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "type": "object", - "properties": { - "processAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/ProcessInfoEntry" - } - } - } + "$ref": "#/definitions/Error" } }, "401": { @@ -3451,6 +3771,12 @@ func init() { "$ref": "#/definitions/Error" } }, + "404": { + "description": "Vlan interface is not defined/Vlan member is not found on this Vlan interface", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -3465,9 +3791,155 @@ func init() { } } } - } + }, + "/metrics": { + "get": { + "summary": "Scrape metrics from the cache", + "responses": { + "200": { + "description": "Metrics in prometheus text format", + "schema": { + "type": "string" + } + } + } + } + }, + "/status/device": { + "get": { + "description": "Get a basic info (linux command \"uptime, hostnamectl\") in the device or system.", + "summary": "Get a basic info in the device", + "responses": { + "200": { + "description": "Device unique informations", + "schema": { + "$ref": "#/definitions/DeviceInfoEntry" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/status/filesystem": { + "get": { + "description": "Get a File system infomation (linux command \"df\") in the device or system.", + "summary": "Get a File System info in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "filesystemAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/FileSystemInfoEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/status/process": { + "get": { + "description": "Get a process based on high usage CPU(linux command \"top\") in the device or system.", + "summary": "Get a process based on CPU usage info in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "processAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/ProcessInfoEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } }, "definitions": { + "BGPApplyPolicyToNeighborMod": { + "type": "object", + "properties": { + "ipAddress": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "policies": { + "type": "array", + "items": { + "type": "string" + } + }, + "policyType": { + "type": "string" + }, + "routeAction": { + "type": "string" + } + } + }, "BGPGlobalConfig": { "type": "object", "properties": { @@ -3531,6 +4003,264 @@ func init() { } } }, + "BGPPolicyDefinedSetGetEntry": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "BGP Defined set Entries", + "type": "string" + }, + "prefixList": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyPrefix" + } + } + } + }, + "BGPPolicyDefinedSetsMod": { + "type": "object", + "properties": { + "List": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "prefixList": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyPrefix" + } + } + } + }, + "BGPPolicyDefinitionsMod": { + "type": "object", + "properties": { + "name": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "statements": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyDefinitionsStatement" + } + } + } + }, + "BGPPolicyDefinitionsStatement": { + "type": "object", + "properties": { + "actions": { + "type": "object", + "properties": { + "bgpActions": { + "type": "object", + "properties": { + "setAsPathPrepend": { + "type": "object", + "properties": { + "as": { + "type": "string" + }, + "repeatN": { + "type": "integer" + } + } + }, + "setCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setExtCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLargeCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLocalPerf": { + "type": "integer" + }, + "setMed": { + "type": "string" + }, + "setNextHop": { + "type": "string" + } + } + }, + "routeDisposition": { + "type": "string" + } + } + }, + "conditions": { + "type": "object", + "properties": { + "bgpConditions": { + "type": "object", + "properties": { + "afiSafiIn": { + "type": "array", + "items": { + "type": "string" + } + }, + "asPathLength": { + "type": "object", + "properties": { + "operator": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "matchAsPathSet": { + "type": "object", + "properties": { + "asPathSet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchExtCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchLargeCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "nextHopInList": { + "type": "array", + "items": { + "type": "string" + } + }, + "routeType": { + "type": "string" + }, + "rpki": { + "type": "string" + } + } + }, + "matchNeighborSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "neighborSet": { + "type": "string" + } + } + }, + "matchPrefixSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "prefixSet": { + "type": "string" + } + } + } + } + }, + "name": { + "type": "string" + } + } + }, + "BGPPolicyPrefix": { + "type": "object", + "properties": { + "ipPrefix": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "masklengthRange": { + "description": "Remote AS number", + "type": "string" + } + } + }, "BfdEntry": { "type": "object", "properties": { @@ -5197,18 +5927,18 @@ func init() { } } }, - "/config/cistate": { + "/config/bgp/policy/apply": { "post": { - "description": "Informs Current Cluster Instance state in the device", - "summary": "Informs Current Cluster Instance state in the device", + "description": "Apply BGP Policy in neighbor", + "summary": "Apply BGP Policy in neighbor", "parameters": [ { - "description": "Attributes for CI State", + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/CIStatusEntry" + "$ref": "#/definitions/BGPApplyPolicyToNeighborMod" } } ], @@ -5261,98 +5991,25 @@ func init() { } } }, - "/config/cistate/all": { - "get": { - "description": "Get Cluster Instance State in the device", - "summary": "Get Cluster Instance State in the device", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "Attr": { - "type": "array", - "items": { - "$ref": "#/definitions/CIStatusGetEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/conntrack/all": { - "get": { - "description": "Get all of the conntrack infomation for all of the service.", - "summary": "Get all of the conntrack entries.", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "ctAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/ConntrackEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/endpoint": { + "/config/bgp/policy/definedsets/{defineset_type}": { "post": { - "description": "Adds a LB endpoint for monitoring", - "summary": "Adds a LB endpoint for monitoring", + "description": "Adds a BGP definedsets for making Policy", + "summary": "Adds a BGP definedsets for making Policy", "parameters": [ { - "description": "Attributes of end point", + "type": "string", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", + "in": "path", + "required": true + }, + { + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/EndPoint" + "$ref": "#/definitions/BGPPolicyDefinedSetsMod" } } ], @@ -5405,31 +6062,74 @@ func init() { } } }, - "/config/endpoint/all": { + "/config/bgp/policy/definedsets/{defineset_type}/{type_name}": { "get": { - "description": "Get End-Points State in loxilb", - "summary": "Get End-Points State in loxilb", + "description": "Get the all of BGP, prefix/neighbor/community/extcommunity/aspath/largecommunity", + "summary": "Get the all of BGP definedsets", + "parameters": [ + { + "type": "string", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "type name", + "name": "type_name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "Attr": { + "definedsetsAttr": { "type": "array", "items": { - "$ref": "#/definitions/EndPointGetEntry" + "$ref": "#/definitions/BGPPolicyDefinedSetGetEntry" } } } } }, + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -5443,37 +6143,24 @@ func init() { } } } - } - }, - "/config/endpoint/epipaddress/{ip_address}": { + }, "delete": { - "description": "Delete an LB end-point from monitoring", - "summary": "Delete an LB end-point from monitoring", + "description": "Delete a BGP definedsets", + "summary": "Delete a BGP definedsets", "parameters": [ { "type": "string", - "description": "Attributes of end point", - "name": "ip_address", + "description": "defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity", + "name": "defineset_type", "in": "path", "required": true }, { "type": "string", - "description": "Endpoint Identifier", - "name": "name", - "in": "query" - }, - { - "type": "string", - "description": "Probe type", - "name": "probe_type", - "in": "query" - }, - { - "type": "number", - "description": "Probe port", - "name": "probe_port", - "in": "query" + "description": "type name", + "name": "type_name", + "in": "path", + "required": true } ], "responses": { @@ -5505,7 +6192,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. Neigh already exists", "schema": { "$ref": "#/definitions/Error" } @@ -5525,18 +6212,18 @@ func init() { } } }, - "/config/fdb": { + "/config/bgp/policy/definitions": { "post": { - "description": "Assign FDB in the device", - "summary": "Assign FDB in the device", + "description": "Adds a BGP Policy", + "summary": "Adds a BGP Policy", "parameters": [ { - "description": "Attributes for IPv4 address", + "description": "Attributes of bgp neighbor", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/FDBEntry" + "$ref": "#/definitions/BGPPolicyDefinitionsMod" } } ], @@ -5569,7 +6256,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -5589,20 +6276,20 @@ func init() { } } }, - "/config/fdb/all": { + "/config/bgp/policy/definitions/all": { "get": { - "description": "Get FDB in the device(interface).", - "summary": "Get FDB in the device(interface)", + "description": "Get BGP Policy definitions", + "summary": "Get BGP Policy definitions", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "fdbAttr": { + "bgpPolicyAttr": { "type": "array", "items": { - "$ref": "#/definitions/FDBEntry" + "$ref": "#/definitions/BGPPolicyDefinitionsMod" } } } @@ -5629,22 +6316,15 @@ func init() { } } }, - "/config/fdb/{mac_address}/dev/{if_name}": { + "/config/bgp/policy/definitions/{policy_name}": { "delete": { - "description": "Delete FDB in the device", - "summary": "Delete FDB in the device", + "description": "Delete a BGP Policy", + "summary": "Delete a BGP policy", "parameters": [ { "type": "string", - "description": "Attributes IPv4 Address in the device", - "name": "mac_address", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Attributes of the target device", - "name": "if_name", + "description": "The name of the community", + "name": "policy_name", "in": "path", "required": true } @@ -5678,7 +6358,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. Neigh already exists", "schema": { "$ref": "#/definitions/Error" } @@ -5698,18 +6378,18 @@ func init() { } } }, - "/config/firewall": { + "/config/cistate": { "post": { - "description": "Create a new firewall config for security.", - "summary": "Create a new firewall config", + "description": "Informs Current Cluster Instance state in the device", + "summary": "Informs Current Cluster Instance state in the device", "parameters": [ { - "description": "Attributes for firewall sevice", + "description": "Attributes for CI State", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/FirewallEntry" + "$ref": "#/definitions/CIStatusEntry" } } ], @@ -5742,7 +6422,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -5760,105 +6440,38 @@ func init() { } } } - }, - "delete": { - "description": "Delete of the firewall service.", - "summary": "Delete of the firewall service", - "parameters": [ - { - "type": "string", - "description": "Source IP address", - "name": "sourceIP", - "in": "query" + } + }, + "/config/cistate/all": { + "get": { + "description": "Get Cluster Instance State in the device", + "summary": "Get Cluster Instance State in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "Attr": { + "type": "array", + "items": { + "$ref": "#/definitions/CIStatusGetEntry" + } + } + } + } }, - { - "type": "string", - "description": "Destination IP in CIDR notation", - "name": "destinationIP", - "in": "query" + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } }, - { - "type": "integer", - "description": "Minimum source port range", - "name": "minSourcePort", - "in": "query" - }, - { - "type": "integer", - "description": "Maximum source port range", - "name": "maxSourcePort", - "in": "query" - }, - { - "type": "integer", - "description": "Minimum destination port range", - "name": "minDestinationPort", - "in": "query" - }, - { - "type": "integer", - "description": "Maximum destination port range", - "name": "maxDestinationPort", - "in": "query" - }, - { - "type": "integer", - "description": "the protocol", - "name": "protocol", - "in": "query" - }, - { - "type": "string", - "description": "the incoming port", - "name": "portName", - "in": "query" - }, - { - "type": "integer", - "description": "User preference for ordering", - "name": "preference", - "in": "query" - } - ], - "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } }, "503": { "description": "Maintanence mode", @@ -5869,20 +6482,20 @@ func init() { } } }, - "/config/firewall/all": { + "/config/conntrack/all": { "get": { - "description": "Get all of the firewall configuration.", - "summary": "Get all of the firewall config", + "description": "Get all of the conntrack infomation for all of the service.", + "summary": "Get all of the conntrack entries.", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "fwAttr": { + "ctAttr": { "type": "array", "items": { - "$ref": "#/definitions/FirewallEntry" + "$ref": "#/definitions/ConntrackEntry" } } } @@ -5909,18 +6522,18 @@ func init() { } } }, - "/config/ipv4address": { + "/config/endpoint": { "post": { - "description": "Assign IPv4 addresses in the device", - "summary": "Assign IPv4 addresses in the device", + "description": "Adds a LB endpoint for monitoring", + "summary": "Adds a LB endpoint for monitoring", "parameters": [ { - "description": "Attributes for IPv4 address", + "description": "Attributes of end point", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/IPv4AddressEntry" + "$ref": "#/definitions/EndPoint" } } ], @@ -5953,7 +6566,7 @@ func init() { } }, "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict.", "schema": { "$ref": "#/definitions/Error" } @@ -5973,20 +6586,20 @@ func init() { } } }, - "/config/ipv4address/all": { + "/config/endpoint/all": { "get": { - "description": "Get IPv4 addresses in the device(interface)", - "summary": "Get IPv4 addresses in the device(interface)", + "description": "Get End-Points State in loxilb", + "summary": "Get End-Points State in loxilb", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "ipAttr": { + "Attr": { "type": "array", "items": { - "$ref": "#/definitions/IPv4AddressGetEntry" + "$ref": "#/definitions/EndPointGetEntry" } } } @@ -6013,31 +6626,35 @@ func init() { } } }, - "/config/ipv4address/{ip_address}/{mask}/dev/{if_name}": { + "/config/endpoint/epipaddress/{ip_address}": { "delete": { - "description": "Delete IPv4 addresses in the device", - "summary": "Delete IPv4 addresses in the device", + "description": "Delete an LB end-point from monitoring", + "summary": "Delete an LB end-point from monitoring", "parameters": [ { "type": "string", - "description": "Attributes IPv4 Address in the device", + "description": "Attributes of end point", "name": "ip_address", "in": "path", "required": true }, { "type": "string", - "description": "Attributes IPv4 mask in the device", - "name": "mask", - "in": "path", - "required": true + "description": "Endpoint Identifier", + "name": "name", + "in": "query" }, { "type": "string", - "description": "Attributes of the target device", - "name": "if_name", - "in": "path", - "required": true + "description": "Probe type", + "name": "probe_type", + "in": "query" + }, + { + "type": "number", + "description": "Probe port", + "name": "probe_port", + "in": "query" } ], "responses": { @@ -6089,27 +6706,24 @@ func init() { } } }, - "/config/loadbalancer": { + "/config/fdb": { "post": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", + "description": "Assign FDB in the device", + "summary": "Assign FDB in the device", "parameters": [ { - "description": "Attributes for load balance service", + "description": "Attributes for IPv4 address", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/LoadbalanceEntry" + "$ref": "#/definitions/FDBEntry" } } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/PostSuccess" - } + "204": { + "description": "OK" }, "400": { "description": "Malformed arguments for API call", @@ -6156,20 +6770,20 @@ func init() { } } }, - "/config/loadbalancer/all": { + "/config/fdb/all": { "get": { - "description": "Get all of the load balancer services with conntrack infomation.", - "summary": "Get all of the load balancer services", + "description": "Get FDB in the device(interface).", + "summary": "Get FDB in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "lbAttr": { + "fdbAttr": { "type": "array", "items": { - "$ref": "#/definitions/LoadbalanceEntry" + "$ref": "#/definitions/FDBEntry" } } } @@ -6194,96 +6808,26 @@ func init() { } } } - }, - "delete": { - "description": "Delete all load balancer services.", - "summary": "Delete all Load balancer services", - "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } } }, - "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "/config/fdb/{mac_address}/dev/{if_name}": { "delete": { - "description": "Delete an existing load balancer service with .", - "summary": "Delete an existing Load balancer service", + "description": "Delete FDB in the device", + "summary": "Delete FDB in the device", "parameters": [ { "type": "string", - "description": "Attributes for load balance service", - "name": "ip_address", - "in": "path", - "required": true - }, - { - "type": "number", - "description": "Attributes for load balance service", - "name": "port", + "description": "Attributes IPv4 Address in the device", + "name": "mac_address", "in": "path", "required": true }, { "type": "string", - "description": "Attributes for load balance service", - "name": "proto", + "description": "Attributes of the target device", + "name": "if_name", "in": "path", "required": true - }, - { - "type": "boolean", - "description": "option for BGP enable", - "name": "bgp", - "in": "query" - }, - { - "type": "number", - "description": "block value if any", - "name": "block", - "in": "query" } ], "responses": { @@ -6335,18 +6879,18 @@ func init() { } } }, - "/config/mirror": { + "/config/firewall": { "post": { - "description": "Create a new Mirror config.", - "summary": "Create a new Mirror config", + "description": "Create a new firewall config for security.", + "summary": "Create a new firewall config", "parameters": [ { - "description": "Attributes for Mirror", + "description": "Attributes for firewall sevice", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/MirrorEntry" + "$ref": "#/definitions/FirewallEntry" } } ], @@ -6397,59 +6941,64 @@ func init() { } } } - } - }, - "/config/mirror/all": { - "get": { - "description": "Get", - "summary": "Get", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "mirrAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/MirrorGetEntry" - } - } - } - } + }, + "delete": { + "description": "Delete of the firewall service.", + "summary": "Delete of the firewall service", + "parameters": [ + { + "type": "string", + "description": "Source IP address", + "name": "sourceIP", + "in": "query" }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } + { + "type": "string", + "description": "Destination IP in CIDR notation", + "name": "destinationIP", + "in": "query" }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } + { + "type": "integer", + "description": "Minimum source port range", + "name": "minSourcePort", + "in": "query" + }, + { + "type": "integer", + "description": "Maximum source port range", + "name": "maxSourcePort", + "in": "query" + }, + { + "type": "integer", + "description": "Minimum destination port range", + "name": "minDestinationPort", + "in": "query" + }, + { + "type": "integer", + "description": "Maximum destination port range", + "name": "maxDestinationPort", + "in": "query" + }, + { + "type": "integer", + "description": "the protocol", + "name": "protocol", + "in": "query" }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/mirror/ident/{ident}": { - "delete": { - "description": "Delete a new Create a Mirror service.", - "summary": "Delete a Mirror service", - "parameters": [ { "type": "string", - "description": "Attributes of Mirror Ident.", - "name": "ident", - "in": "path", - "required": true + "description": "the incoming port", + "name": "portName", + "in": "query" + }, + { + "type": "integer", + "description": "User preference for ordering", + "name": "preference", + "in": "query" } ], "responses": { @@ -6501,10 +7050,50 @@ func init() { } } }, - "/config/neighbor": { + "/config/firewall/all": { + "get": { + "description": "Get all of the firewall configuration.", + "summary": "Get all of the firewall config", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "fwAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/FirewallEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/ipv4address": { "post": { - "description": "Assign IPv4 neighbor in the device", - "summary": "Assign IPv4 neighbor in the device", + "description": "Assign IPv4 addresses in the device", + "summary": "Assign IPv4 addresses in the device", "parameters": [ { "description": "Attributes for IPv4 address", @@ -6512,7 +7101,7 @@ func init() { "in": "body", "required": true, "schema": { - "$ref": "#/definitions/NeighborEntry" + "$ref": "#/definitions/IPv4AddressEntry" } } ], @@ -6565,20 +7154,20 @@ func init() { } } }, - "/config/neighbor/all": { + "/config/ipv4address/all": { "get": { - "description": "Get IPv4 neighbor in the device(interface)", - "summary": "Get IPv4 neighbor in the device(interface)", + "description": "Get IPv4 addresses in the device(interface)", + "summary": "Get IPv4 addresses in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "neighborAttr": { + "ipAttr": { "type": "array", "items": { - "$ref": "#/definitions/NeighborEntry" + "$ref": "#/definitions/IPv4AddressGetEntry" } } } @@ -6605,10 +7194,10 @@ func init() { } } }, - "/config/neighbor/{ip_address}/dev/{if_name}": { + "/config/ipv4address/{ip_address}/{mask}/dev/{if_name}": { "delete": { - "description": "Delete IPv4 neighbor in the device", - "summary": "Delete IPv4 neighbor in the device", + "description": "Delete IPv4 addresses in the device", + "summary": "Delete IPv4 addresses in the device", "parameters": [ { "type": "string", @@ -6617,6 +7206,13 @@ func init() { "in": "path", "required": true }, + { + "type": "string", + "description": "Attributes IPv4 mask in the device", + "name": "mask", + "in": "path", + "required": true + }, { "type": "string", "description": "Attributes of the target device", @@ -6674,20 +7270,28 @@ func init() { } } }, - "/config/params": { - "get": { - "description": "Get Operational params of LoxiLB", - "summary": "Get Operational params of LoxiLB", + "/config/loadbalancer": { + "post": { + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", + "parameters": [ + { + "description": "Attributes for load balance service", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/LoadbalanceEntry" + } + } + ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/OperParams" + "$ref": "#/definitions/PostSuccess" } }, - "204": { - "description": "OK" - }, "400": { "description": "Malformed arguments for API call", "schema": { @@ -6731,21 +7335,50 @@ func init() { } } } - }, - "post": { - "description": "Set Operational parameters of LoxiLB", - "summary": "Set Operational parameters of LoxiLB", - "parameters": [ - { - "description": "Attributes for setting state", - "name": "attr", - "in": "body", - "required": true, + } + }, + "/config/loadbalancer/all": { + "get": { + "description": "Get all of the load balancer services with conntrack infomation.", + "summary": "Get all of the load balancer services", + "responses": { + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/OperParams" + "type": "object", + "properties": { + "lbAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/LoadbalanceEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" } } - ], + } + }, + "delete": { + "description": "Delete all load balancer services.", + "summary": "Delete all Load balancer services", "responses": { "204": { "description": "OK" @@ -6795,18 +7428,106 @@ func init() { } } }, - "/config/policy": { - "post": { - "description": "Create a new Policy QoS config.", - "summary": "Create a new Policy QoS config", + "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "delete": { + "description": "Delete an existing load balancer service with .", + "summary": "Delete an existing Load balancer service", "parameters": [ { - "description": "Attributes for Policy", - "name": "attr", + "type": "string", + "description": "Attributes for load balance service", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "number", + "description": "Attributes for load balance service", + "name": "port", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for load balance service", + "name": "proto", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "option for BGP enable", + "name": "bgp", + "in": "query" + }, + { + "type": "number", + "description": "block value if any", + "name": "block", + "in": "query" + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/mirror": { + "post": { + "description": "Create a new Mirror config.", + "summary": "Create a new Mirror config", + "parameters": [ + { + "description": "Attributes for Mirror", + "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/PolicyEntry" + "$ref": "#/definitions/MirrorEntry" } } ], @@ -6859,7 +7580,7 @@ func init() { } } }, - "/config/policy/all": { + "/config/mirror/all": { "get": { "description": "Get", "summary": "Get", @@ -6869,10 +7590,10 @@ func init() { "schema": { "type": "object", "properties": { - "polAttr": { + "mirrAttr": { "type": "array", "items": { - "$ref": "#/definitions/PolicyEntry" + "$ref": "#/definitions/MirrorGetEntry" } } } @@ -6899,14 +7620,14 @@ func init() { } } }, - "/config/policy/ident/{ident}": { + "/config/mirror/ident/{ident}": { "delete": { - "description": "Delete a new Create a Policy QoS service.", - "summary": "Delete a Policy QoS service", + "description": "Delete a new Create a Mirror service.", + "summary": "Delete a Mirror service", "parameters": [ { "type": "string", - "description": "Attributes of Policy Ident.", + "description": "Attributes of Mirror Ident.", "name": "ident", "in": "path", "required": true @@ -6961,58 +7682,18 @@ func init() { } } }, - "/config/port/all": { - "get": { - "description": "Get all of the port interfaces.", - "summary": "Get all of the port interfaces", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "properties": { - "portAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/PortEntry" - } - } - } - } - }, - "401": { - "description": "Invalid authentication credentials", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "500": { - "description": "Internal service error", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "503": { - "description": "Maintanence mode", - "schema": { - "$ref": "#/definitions/Error" - } - } - } - } - }, - "/config/route": { + "/config/neighbor": { "post": { - "description": "Create a new route config .", - "summary": "Create a new route config", + "description": "Assign IPv4 neighbor in the device", + "summary": "Assign IPv4 neighbor in the device", "parameters": [ { - "description": "Attributes for load balance service", + "description": "Attributes for IPv4 address", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/RouteEntry" + "$ref": "#/definitions/NeighborEntry" } } ], @@ -7065,25 +7746,70 @@ func init() { } } }, - "/config/route/all": { + "/config/neighbor/all": { "get": { - "description": "Get all route table", - "summary": "Get all route table", + "description": "Get IPv4 neighbor in the device(interface)", + "summary": "Get IPv4 neighbor in the device(interface)", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "routeAttr": { + "neighborAttr": { "type": "array", "items": { - "$ref": "#/definitions/RouteGetEntry" + "$ref": "#/definitions/NeighborEntry" } } } } }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/neighbor/{ip_address}/dev/{if_name}": { + "delete": { + "description": "Delete IPv4 neighbor in the device", + "summary": "Delete IPv4 neighbor in the device", + "parameters": [ + { + "type": "string", + "description": "Attributes IPv4 Address in the device", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes of the target device", + "name": "if_name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "OK" + }, "400": { "description": "Malformed arguments for API call", "schema": { @@ -7129,27 +7855,17 @@ func init() { } } }, - "/config/route/destinationIPNet/{ip_address}/{mask}": { - "delete": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", - "parameters": [ - { - "type": "string", - "description": "Attributes for destinaion route address", - "name": "ip_address", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Attributes for destination route", - "name": "mask", - "in": "path", - "required": true - } - ], + "/config/params": { + "get": { + "description": "Get Operational params of LoxiLB", + "summary": "Get Operational params of LoxiLB", "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/OperParams" + } + }, "204": { "description": "OK" }, @@ -7196,20 +7912,18 @@ func init() { } } } - } - }, - "/config/session": { + }, "post": { - "description": "Create a new session config for 5G.", - "summary": "Create a new session config", + "description": "Set Operational parameters of LoxiLB", + "summary": "Set Operational parameters of LoxiLB", "parameters": [ { - "description": "Attributes for 5G service session", + "description": "Attributes for setting state", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/SessionEntry" + "$ref": "#/definitions/OperParams" } } ], @@ -7262,20 +7976,84 @@ func init() { } } }, - "/config/session/all": { - "get": { - "description": "Get all of the port interfaces.", - "summary": "Get all of the port interfaces", + "/config/policy": { + "post": { + "description": "Create a new Policy QoS config.", + "summary": "Create a new Policy QoS config", + "parameters": [ + { + "description": "Attributes for Policy", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PolicyEntry" + } + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/policy/all": { + "get": { + "description": "Get", + "summary": "Get", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "sessionAttr": { + "polAttr": { "type": "array", "items": { - "$ref": "#/definitions/SessionEntry" + "$ref": "#/definitions/PolicyEntry" } } } @@ -7302,14 +8080,14 @@ func init() { } } }, - "/config/session/ident/{ident}": { + "/config/policy/ident/{ident}": { "delete": { - "description": "Create a new load balancer service with .", - "summary": "Create a new Load balancer service", + "description": "Delete a new Create a Policy QoS service.", + "summary": "Delete a Policy QoS service", "parameters": [ { "type": "string", - "description": "Attributes 5G session Ident.", + "description": "Attributes of Policy Ident.", "name": "ident", "in": "path", "required": true @@ -7364,18 +8142,58 @@ func init() { } } }, - "/config/sessionulcl": { + "/config/port/all": { + "get": { + "description": "Get all of the port interfaces.", + "summary": "Get all of the port interfaces", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "portAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/PortEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/route": { "post": { - "description": "Create a new session config for 5G.", - "summary": "Create a new session config", + "description": "Create a new route config .", + "summary": "Create a new route config", "parameters": [ { - "description": "Attributes for 5G service session", + "description": "Attributes for load balance service", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/SessionUlClEntry" + "$ref": "#/definitions/RouteEntry" } } ], @@ -7428,31 +8246,55 @@ func init() { } } }, - "/config/sessionulcl/all": { + "/config/route/all": { "get": { - "description": "Get", - "summary": "Get", + "description": "Get all route table", + "summary": "Get all route table", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "ulclAttr": { + "routeAttr": { "type": "array", "items": { - "$ref": "#/definitions/SessionUlClEntry" + "$ref": "#/definitions/RouteGetEntry" } } } } }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -7468,22 +8310,22 @@ func init() { } } }, - "/config/sessionulcl/ident/{ident}/ulclAddress/{ip_address}": { + "/config/route/destinationIPNet/{ip_address}/{mask}": { "delete": { "description": "Create a new load balancer service with .", "summary": "Create a new Load balancer service", "parameters": [ { "type": "string", - "description": "Attributes 5G session Ident.", - "name": "ident", + "description": "Attributes for destinaion route address", + "name": "ip_address", "in": "path", "required": true }, { - "type": "string", - "description": "Attributes for session ulcl address", - "name": "ip_address", + "type": "integer", + "description": "Attributes for destination route", + "name": "mask", "in": "path", "required": true } @@ -7537,18 +8379,18 @@ func init() { } } }, - "/config/tunnel/vxlan": { + "/config/session": { "post": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Add a one of vxlan configuration", + "description": "Create a new session config for 5G.", + "summary": "Create a new session config", "parameters": [ { - "description": "attributes for vxlan member interface", + "description": "Attributes for 5G service session", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VxlanBridgeEntry" + "$ref": "#/definitions/SessionEntry" } } ], @@ -7556,14 +8398,32 @@ func init() { "204": { "description": "OK" }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "409": { - "description": "Resource Conflict. VxLAN already exists OR dependency VRF/VNET not found", + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", "schema": { "$ref": "#/definitions/Error" } @@ -7583,20 +8443,20 @@ func init() { } } }, - "/config/tunnel/vxlan/all": { + "/config/session/all": { "get": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Get a list of vxlan configurations", + "description": "Get all of the port interfaces.", + "summary": "Get all of the port interfaces", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "vxlanAttr": { + "sessionAttr": { "type": "array", "items": { - "$ref": "#/definitions/VxlanEntry" + "$ref": "#/definitions/SessionEntry" } } } @@ -7623,16 +8483,15 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}": { + "/config/session/ident/{ident}": { "delete": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Delete a one of vxlan configuration", + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", "parameters": [ { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", + "type": "string", + "description": "Attributes 5G session Ident.", + "name": "ident", "in": "path", "required": true } @@ -7641,12 +8500,36 @@ func init() { "204": { "description": "OK" }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -7662,34 +8545,29 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}/peer": { + "/config/sessionulcl": { "post": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Add a one of vxlan remote(peer) ip address configuration", + "description": "Create a new session config for 5G.", + "summary": "Create a new session config", "parameters": [ { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", - "in": "path", - "required": true - }, - { - "description": "attributes for vxlan Peer interface", + "description": "Attributes for 5G service session", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VxlanPeerEntry" + "$ref": "#/definitions/SessionUlClEntry" } } ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "$ref": "#/definitions/VxlanPeerEntry" + "$ref": "#/definitions/Error" } }, "401": { @@ -7698,6 +8576,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -7713,32 +8609,23 @@ func init() { } } }, - "/config/tunnel/vxlan/{vxlanID}/peer/{PeerIP}": { - "delete": { - "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", - "summary": "Remove a one of vxlan remote(peer) ip address configuration", - "parameters": [ - { - "type": "integer", - "format": "int32", - "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", - "name": "vxlanID", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "attributes for vxlan Peer IP address", - "name": "PeerIP", - "in": "path", - "required": true - } - ], + "/config/sessionulcl/all": { + "get": { + "description": "Get", + "summary": "Get", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/VxlanEntry" + "type": "object", + "properties": { + "ulclAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/SessionUlClEntry" + } + } + } } }, "401": { @@ -7762,19 +8649,24 @@ func init() { } } }, - "/config/vlan": { - "post": { - "description": "Create vlan interface in the device", - "summary": "Create vlan interface in the device", + "/config/sessionulcl/ident/{ident}/ulclAddress/{ip_address}": { + "delete": { + "description": "Create a new load balancer service with .", + "summary": "Create a new Load balancer service", "parameters": [ { - "description": "Attributes for Vlan Interface", - "name": "attr", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/VlanBridgeEntry" - } + "type": "string", + "description": "Attributes 5G session Ident.", + "name": "ident", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for session ulcl address", + "name": "ip_address", + "in": "path", + "required": true } ], "responses": { @@ -7826,20 +8718,66 @@ func init() { } } }, - "/config/vlan/all": { + "/config/tunnel/vxlan": { + "post": { + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Add a one of vxlan configuration", + "parameters": [ + { + "description": "attributes for vxlan member interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VxlanBridgeEntry" + } + } + ], + "responses": { + "204": { + "description": "OK" + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VxLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/tunnel/vxlan/all": { "get": { - "description": "Get vlan in the device", - "summary": "Get vlan in the device", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Get a list of vxlan configurations", "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { - "vlanAttr": { + "vxlanAttr": { "type": "array", "items": { - "$ref": "#/definitions/VlanGetEntry" + "$ref": "#/definitions/VxlanEntry" } } } @@ -7866,15 +8804,16 @@ func init() { } } }, - "/config/vlan/{vlan_id}": { + "/config/tunnel/vxlan/{vxlanID}": { "delete": { - "description": "Delete vlan in the device", - "summary": "Delete vlan in the device", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Delete a one of vxlan configuration", "parameters": [ { "type": "integer", - "description": "Attributes IPv4 Address in the device", - "name": "vlan_id", + "format": "int32", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true } @@ -7883,36 +8822,12 @@ func init() { "204": { "description": "OK" }, - "400": { - "description": "Malformed arguments for API call", - "schema": { - "$ref": "#/definitions/Error" - } - }, "401": { "description": "Invalid authentication credentials", "schema": { "$ref": "#/definitions/Error" } }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Resource not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", - "schema": { - "$ref": "#/definitions/Error" - } - }, "500": { "description": "Internal service error", "schema": { @@ -7928,37 +8843,34 @@ func init() { } } }, - "/config/vlan/{vlan_id}/member": { + "/config/tunnel/vxlan/{vxlanID}/peer": { "post": { - "description": "Add a member to interface Vlan{vlan_id}. If the vlan interface does not exist on LoxiLB it returns a '404' error. If such a member is already present on this Vlan interface the API returns '409' sub-code 0. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'. If attr with tagging mode is provided it will be honored in config, if not, the default tagging mode will be set to 'untagged'. Vlan members may be tagged or untagged, but, the Vlan member port may be untagged in only one Vlan interface, deviations from this will cause the API to return '409' sub-code 0.", - "summary": "Add a physical port to a vlan interface", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Add a one of vxlan remote(peer) ip address configuration", "parameters": [ { "type": "integer", "format": "int32", - "description": "12 bit vlan_id", - "name": "vlan_id", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true }, { - "description": "Attributes for Vlan Interface", + "description": "attributes for vxlan Peer interface", "name": "attr", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/VlanMemberEntry" + "$ref": "#/definitions/VxlanPeerEntry" } } ], "responses": { - "204": { - "description": "OK" - }, - "400": { - "description": "Malformed arguments for API call", + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/Error" + "$ref": "#/definitions/VxlanPeerEntry" } }, "401": { @@ -7967,24 +8879,6 @@ func init() { "$ref": "#/definitions/Error" } }, - "403": { - "description": "Capacity insufficient", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "404": { - "description": "Vlan interface is not defined", - "schema": { - "$ref": "#/definitions/Error" - } - }, - "409": { - "description": "Resource Conflict. VLAN member already exists on this VLAN interface OR Vlan member is being added to 2nd Vlan inteface as an untagged member.", - "schema": { - "$ref": "#/definitions/Error" - } - }, "500": { "description": "Internal service error", "schema": { @@ -8000,34 +8894,70 @@ func init() { } } }, - "/config/vlan/{vlan_id}/member/{if_name}/tagged/{tagged}": { + "/config/tunnel/vxlan/{vxlanID}/peer/{PeerIP}": { "delete": { - "description": "Remove a vlan member from a vlan interface which is defined by vlan_id. If the Vlan interface does not exist on LoxiLB OR a vlan member 'if_name' is not present on the interface the API will return '404'. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'.", - "summary": "Remove a vlan member from a vlan interface", + "description": "Return a list of existing tunnels of a type. If there're no tunnels to return, empty list will be returned.", + "summary": "Remove a one of vxlan remote(peer) ip address configuration", "parameters": [ { "type": "integer", "format": "int32", - "description": "12 bit vlan_id", - "name": "vlan_id", + "description": "vxlan id (24-bit). Allows to remove routes with defined vnid only. Applicable for routes with nexthop_type 'vxlan-tunnel'. Otherwise '400' error will be returned", + "name": "vxlanID", "in": "path", "required": true }, { "type": "string", - "description": "Physical port name", - "name": "if_name", - "in": "path", - "required": true - }, - { - "type": "boolean", - "description": "Tagged status", - "name": "tagged", + "description": "attributes for vxlan Peer IP address", + "name": "PeerIP", "in": "path", "required": true } ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/VxlanEntry" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/vlan": { + "post": { + "description": "Create vlan interface in the device", + "summary": "Create vlan interface in the device", + "parameters": [ + { + "description": "Attributes for Vlan Interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VlanBridgeEntry" + } + } + ], "responses": { "204": { "description": "OK" @@ -8044,8 +8974,20 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, "404": { - "description": "Vlan interface is not defined/Vlan member is not found on this Vlan interface", + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", "schema": { "$ref": "#/definitions/Error" } @@ -8065,28 +9007,67 @@ func init() { } } }, - "/metrics": { + "/config/vlan/all": { "get": { - "summary": "Scrape metrics from the cache", + "description": "Get vlan in the device", + "summary": "Get vlan in the device", "responses": { "200": { - "description": "Metrics in prometheus text format", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "properties": { + "vlanAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/VlanGetEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" } } } } }, - "/status/device": { - "get": { - "description": "Get a basic info (linux command \"uptime, hostnamectl\") in the device or system.", - "summary": "Get a basic info in the device", + "/config/vlan/{vlan_id}": { + "delete": { + "description": "Delete vlan in the device", + "summary": "Delete vlan in the device", + "parameters": [ + { + "type": "integer", + "description": "Attributes IPv4 Address in the device", + "name": "vlan_id", + "in": "path", + "required": true + } + ], "responses": { - "200": { - "description": "Device unique informations", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "$ref": "#/definitions/DeviceInfoEntry" + "$ref": "#/definitions/Error" } }, "401": { @@ -8095,6 +9076,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -8110,23 +9109,37 @@ func init() { } } }, - "/status/filesystem": { - "get": { - "description": "Get a File system infomation (linux command \"df\") in the device or system.", - "summary": "Get a File System info in the device", + "/config/vlan/{vlan_id}/member": { + "post": { + "description": "Add a member to interface Vlan{vlan_id}. If the vlan interface does not exist on LoxiLB it returns a '404' error. If such a member is already present on this Vlan interface the API returns '409' sub-code 0. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'. If attr with tagging mode is provided it will be honored in config, if not, the default tagging mode will be set to 'untagged'. Vlan members may be tagged or untagged, but, the Vlan member port may be untagged in only one Vlan interface, deviations from this will cause the API to return '409' sub-code 0.", + "summary": "Add a physical port to a vlan interface", + "parameters": [ + { + "type": "integer", + "format": "int32", + "description": "12 bit vlan_id", + "name": "vlan_id", + "in": "path", + "required": true + }, + { + "description": "Attributes for Vlan Interface", + "name": "attr", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/VlanMemberEntry" + } + } + ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "type": "object", - "properties": { - "filesystemAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/FileSystemInfoEntry" - } - } - } + "$ref": "#/definitions/Error" } }, "401": { @@ -8135,6 +9148,24 @@ func init() { "$ref": "#/definitions/Error" } }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Vlan interface is not defined", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN member already exists on this VLAN interface OR Vlan member is being added to 2nd Vlan inteface as an untagged member.", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -8150,23 +9181,42 @@ func init() { } } }, - "/status/process": { - "get": { - "description": "Get a process based on high usage CPU(linux command \"top\") in the device or system.", - "summary": "Get a process based on CPU usage info in the device", + "/config/vlan/{vlan_id}/member/{if_name}/tagged/{tagged}": { + "delete": { + "description": "Remove a vlan member from a vlan interface which is defined by vlan_id. If the Vlan interface does not exist on LoxiLB OR a vlan member 'if_name' is not present on the interface the API will return '404'. If the vlan_id passed is less than 2 or greater than 4094 the API will respond with error '400'.", + "summary": "Remove a vlan member from a vlan interface", + "parameters": [ + { + "type": "integer", + "format": "int32", + "description": "12 bit vlan_id", + "name": "vlan_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Physical port name", + "name": "if_name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Tagged status", + "name": "tagged", + "in": "path", + "required": true + } + ], "responses": { - "200": { - "description": "OK", + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", "schema": { - "type": "object", - "properties": { - "processAttr": { - "type": "array", - "items": { - "$ref": "#/definitions/ProcessInfoEntry" - } - } - } + "$ref": "#/definitions/Error" } }, "401": { @@ -8175,6 +9225,12 @@ func init() { "$ref": "#/definitions/Error" } }, + "404": { + "description": "Vlan interface is not defined/Vlan member is not found on this Vlan interface", + "schema": { + "$ref": "#/definitions/Error" + } + }, "500": { "description": "Internal service error", "schema": { @@ -8189,9 +9245,155 @@ func init() { } } } - } + }, + "/metrics": { + "get": { + "summary": "Scrape metrics from the cache", + "responses": { + "200": { + "description": "Metrics in prometheus text format", + "schema": { + "type": "string" + } + } + } + } + }, + "/status/device": { + "get": { + "description": "Get a basic info (linux command \"uptime, hostnamectl\") in the device or system.", + "summary": "Get a basic info in the device", + "responses": { + "200": { + "description": "Device unique informations", + "schema": { + "$ref": "#/definitions/DeviceInfoEntry" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/status/filesystem": { + "get": { + "description": "Get a File system infomation (linux command \"df\") in the device or system.", + "summary": "Get a File System info in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "filesystemAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/FileSystemInfoEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/status/process": { + "get": { + "description": "Get a process based on high usage CPU(linux command \"top\") in the device or system.", + "summary": "Get a process based on CPU usage info in the device", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "properties": { + "processAttr": { + "type": "array", + "items": { + "$ref": "#/definitions/ProcessInfoEntry" + } + } + } + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } }, "definitions": { + "BGPApplyPolicyToNeighborMod": { + "type": "object", + "properties": { + "ipAddress": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "policies": { + "type": "array", + "items": { + "type": "string" + } + }, + "policyType": { + "type": "string" + }, + "routeAction": { + "type": "string" + } + } + }, "BGPGlobalConfig": { "type": "object", "properties": { @@ -8255,6 +9457,719 @@ func init() { } } }, + "BGPPolicyDefinedSetGetEntry": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "BGP Defined set Entries", + "type": "string" + }, + "prefixList": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyPrefix" + } + } + } + }, + "BGPPolicyDefinedSetsMod": { + "type": "object", + "properties": { + "List": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "prefixList": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyPrefix" + } + } + } + }, + "BGPPolicyDefinitionsMod": { + "type": "object", + "properties": { + "name": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "statements": { + "type": "array", + "items": { + "$ref": "#/definitions/BGPPolicyDefinitionsStatement" + } + } + } + }, + "BGPPolicyDefinitionsStatement": { + "type": "object", + "properties": { + "actions": { + "type": "object", + "properties": { + "bgpActions": { + "type": "object", + "properties": { + "setAsPathPrepend": { + "type": "object", + "properties": { + "as": { + "type": "string" + }, + "repeatN": { + "type": "integer" + } + } + }, + "setCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setExtCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLargeCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLocalPerf": { + "type": "integer" + }, + "setMed": { + "type": "string" + }, + "setNextHop": { + "type": "string" + } + } + }, + "routeDisposition": { + "type": "string" + } + } + }, + "conditions": { + "type": "object", + "properties": { + "bgpConditions": { + "type": "object", + "properties": { + "afiSafiIn": { + "type": "array", + "items": { + "type": "string" + } + }, + "asPathLength": { + "type": "object", + "properties": { + "operator": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "matchAsPathSet": { + "type": "object", + "properties": { + "asPathSet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchExtCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchLargeCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "nextHopInList": { + "type": "array", + "items": { + "type": "string" + } + }, + "routeType": { + "type": "string" + }, + "rpki": { + "type": "string" + } + } + }, + "matchNeighborSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "neighborSet": { + "type": "string" + } + } + }, + "matchPrefixSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "prefixSet": { + "type": "string" + } + } + } + } + }, + "name": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementActions": { + "type": "object", + "properties": { + "bgpActions": { + "type": "object", + "properties": { + "setAsPathPrepend": { + "type": "object", + "properties": { + "as": { + "type": "string" + }, + "repeatN": { + "type": "integer" + } + } + }, + "setCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setExtCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLargeCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLocalPerf": { + "type": "integer" + }, + "setMed": { + "type": "string" + }, + "setNextHop": { + "type": "string" + } + } + }, + "routeDisposition": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementActionsBgpActions": { + "type": "object", + "properties": { + "setAsPathPrepend": { + "type": "object", + "properties": { + "as": { + "type": "string" + }, + "repeatN": { + "type": "integer" + } + } + }, + "setCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setExtCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLargeCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "setLocalPerf": { + "type": "integer" + }, + "setMed": { + "type": "string" + }, + "setNextHop": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend": { + "type": "object", + "properties": { + "as": { + "type": "string" + }, + "repeatN": { + "type": "integer" + } + } + }, + "BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity": { + "type": "object", + "properties": { + "options": { + "type": "string" + }, + "setCommunityMethod": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "BGPPolicyDefinitionsStatementConditions": { + "type": "object", + "properties": { + "bgpConditions": { + "type": "object", + "properties": { + "afiSafiIn": { + "type": "array", + "items": { + "type": "string" + } + }, + "asPathLength": { + "type": "object", + "properties": { + "operator": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "matchAsPathSet": { + "type": "object", + "properties": { + "asPathSet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchExtCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchLargeCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "nextHopInList": { + "type": "array", + "items": { + "type": "string" + } + }, + "routeType": { + "type": "string" + }, + "rpki": { + "type": "string" + } + } + }, + "matchNeighborSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "neighborSet": { + "type": "string" + } + } + }, + "matchPrefixSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "prefixSet": { + "type": "string" + } + } + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditions": { + "type": "object", + "properties": { + "afiSafiIn": { + "type": "array", + "items": { + "type": "string" + } + }, + "asPathLength": { + "type": "object", + "properties": { + "operator": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "matchAsPathSet": { + "type": "object", + "properties": { + "asPathSet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchExtCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "matchLargeCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "nextHopInList": { + "type": "array", + "items": { + "type": "string" + } + }, + "routeType": { + "type": "string" + }, + "rpki": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength": { + "type": "object", + "properties": { + "operator": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet": { + "type": "object", + "properties": { + "asPathSet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet": { + "type": "object", + "properties": { + "communitySet": { + "type": "string" + }, + "matchSetOptions": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsMatchNeighborSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "neighborSet": { + "type": "string" + } + } + }, + "BGPPolicyDefinitionsStatementConditionsMatchPrefixSet": { + "type": "object", + "properties": { + "matchSetOption": { + "type": "string" + }, + "prefixSet": { + "type": "string" + } + } + }, + "BGPPolicyPrefix": { + "type": "object", + "properties": { + "ipPrefix": { + "description": "BGP Neighbor IP address", + "type": "string" + }, + "masklengthRange": { + "description": "Remote AS number", + "type": "string" + } + } + }, "BfdEntry": { "type": "object", "properties": { diff --git a/api/restapi/handler/gobgp.go b/api/restapi/handler/gobgp.go index fe82d44ba..f093eaa6d 100644 --- a/api/restapi/handler/gobgp.go +++ b/api/restapi/handler/gobgp.go @@ -117,3 +117,301 @@ func ConfigPostBGPGlobal(params operations.PostConfigBgpGlobalParams) middleware } return &ResultResponse{Result: "Success"} } + +func ConfigPostBGPPolicyDefinedsets(params operations.PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Policy Prefix %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + var bgpPolicyDefinedSet cmn.GoBGPPolicyDefinedSetMod + + // name + bgpPolicyDefinedSet.Name = params.Attr.Name + bgpPolicyDefinedSet.DefinedTypeString = params.DefinesetType + + if bgpPolicyDefinedSet.DefinedTypeString == "prefix" || bgpPolicyDefinedSet.DefinedTypeString == "Prefix" { + for _, prefix := range params.Attr.PrefixList { + var tmpPrefix cmn.Prefix + tmpPrefix.IpPrefix = prefix.IPPrefix + tmpPrefix.MasklengthRange = prefix.MasklengthRange + bgpPolicyDefinedSet.PrefixList = append(bgpPolicyDefinedSet.PrefixList, tmpPrefix) + } + + } else { + bgpPolicyDefinedSet.List = params.Attr.List + } + + tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyPrefix : %v\n", bgpPolicyDefinedSet) + _, err := ApiHooks.NetGoBGPPolicyDefinedSetAdd(&bgpPolicyDefinedSet) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + +func ConfigDeleteBGPPolicyDefinedsets(params operations.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + var bgpPolicyConfig cmn.GoBGPPolicyDefinedSetMod + + bgpPolicyConfig.Name = params.TypeName + bgpPolicyConfig.DefinedTypeString = params.DefinesetType + + tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + _, err := ApiHooks.NetGoBGPPolicyDefinedSetDel(&bgpPolicyConfig) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + +func ConfigGetBGPPolicyDefinedSetGet(params operations.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + res, err := ApiHooks.NetGoBGPPolicyDefinedSetGet(params.TypeName, params.DefinesetType) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + result := make([]*models.BGPPolicyDefinedSetGetEntry, 0) + for _, df := range res { + tmpDf := models.BGPPolicyDefinedSetGetEntry{} + tmpDf.Name = df.Name + tmpDf.List = df.List + + if params.DefinesetType == "prefix" { + tmpDf.PrefixList = make([]*models.BGPPolicyPrefix, 0) + for _, prefix := range df.PrefixList { + tmpPrefix := models.BGPPolicyPrefix{ + IPPrefix: prefix.IpPrefix, + MasklengthRange: prefix.MasklengthRange, + } + tmpDf.PrefixList = append(tmpDf.PrefixList, &tmpPrefix) + } + } + + result = append(result, &tmpDf) + } + + return operations.NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK().WithPayload(&operations.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody{DefinedsetsAttr: result}) +} + +func ConfigPostBGPPolicyDefinitions(params operations.PostConfigBgpPolicyDefinitionsParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Policy Prefix %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + var bgpPolicyConfig cmn.GoBGPPolicyDefinitionsMod + + // name + bgpPolicyConfig.Name = params.Attr.Name + // Statement + for _, statement := range params.Attr.Statements { + var tmpStatement cmn.Statement + tmpStatement.Name = statement.Name + // Condition part + if statement.Conditions.MatchNeighborSet != nil { + tmpStatement.Conditions.NeighborSet = cmn.MatchNeighborSet(*statement.Conditions.MatchNeighborSet) + } + if statement.Conditions.MatchPrefixSet != nil { + tmpStatement.Conditions.PrefixSet = cmn.MatchPrefixSet(*statement.Conditions.MatchPrefixSet) + } + if statement.Conditions.BgpConditions != nil { + if len(statement.Conditions.BgpConditions.AfiSafiIn) != 0 { + tmpStatement.Conditions.BGPConditions.AfiSafiIn = statement.Conditions.BgpConditions.AfiSafiIn + } + + if statement.Conditions.BgpConditions.AsPathLength != nil { + tmpStatement.Conditions.BGPConditions.AsPathLength.Operator = statement.Conditions.BgpConditions.AsPathLength.Operator + tmpStatement.Conditions.BGPConditions.AsPathLength.Value = int(statement.Conditions.BgpConditions.AsPathLength.Value) + } + + if statement.Conditions.BgpConditions.MatchAsPathSet != nil { + tmpStatement.Conditions.BGPConditions.AsPathSet = cmn.BGPAsPathSet(*statement.Conditions.BgpConditions.MatchAsPathSet) + } + if statement.Conditions.BgpConditions.MatchCommunitySet != nil { + tmpStatement.Conditions.BGPConditions.CommunitySet = cmn.BGPCommunitySet(*statement.Conditions.BgpConditions.MatchCommunitySet) + } + if statement.Conditions.BgpConditions.MatchExtCommunitySet != nil { + tmpStatement.Conditions.BGPConditions.ExtCommunitySet = cmn.BGPCommunitySet(*statement.Conditions.BgpConditions.MatchExtCommunitySet) + } + + if statement.Conditions.BgpConditions.MatchLargeCommunitySet != nil { + tmpStatement.Conditions.BGPConditions.LargeCommunitySet = cmn.BGPCommunitySet(*statement.Conditions.BgpConditions.MatchLargeCommunitySet) + } + if statement.Conditions.BgpConditions.Rpki != "" { + tmpStatement.Conditions.BGPConditions.Rpki = statement.Conditions.BgpConditions.Rpki + } + if statement.Conditions.BgpConditions.RouteType != "" { + tmpStatement.Conditions.BGPConditions.RouteType = statement.Conditions.BgpConditions.RouteType + } + + if len(statement.Conditions.BgpConditions.NextHopInList) != 0 { + tmpStatement.Conditions.BGPConditions.NextHopInList = statement.Conditions.BgpConditions.NextHopInList + } + } + + // Action Part + tmpStatement.Actions.RouteDisposition = statement.Actions.RouteDisposition + if statement.Actions.BgpActions != nil { + if statement.Actions.BgpActions.SetAsPathPrepend != nil { + tmpStatement.Actions.BGPActions.SetAsPathPrepend.ASN = statement.Actions.BgpActions.SetAsPathPrepend.As + tmpStatement.Actions.BGPActions.SetAsPathPrepend.RepeatN = int(statement.Actions.BgpActions.SetAsPathPrepend.RepeatN) + } + if statement.Actions.BgpActions.SetCommunity != nil { + tmpStatement.Actions.BGPActions.SetCommunity = cmn.SetCommunity(*statement.Actions.BgpActions.SetCommunity) + } + if statement.Actions.BgpActions.SetExtCommunity != nil { + tmpStatement.Actions.BGPActions.SetExtCommunity = cmn.SetCommunity(*statement.Actions.BgpActions.SetExtCommunity) + } + if statement.Actions.BgpActions.SetLargeCommunity != nil { + tmpStatement.Actions.BGPActions.SetLargeCommunity = cmn.SetCommunity(*statement.Actions.BgpActions.SetLargeCommunity) + } + if statement.Actions.BgpActions.SetMed != "" { + tmpStatement.Actions.BGPActions.SetMed = statement.Actions.BgpActions.SetMed + } + if statement.Actions.BgpActions.SetLocalPerf != 0 { + tmpStatement.Actions.BGPActions.SetLocalPerf = int(statement.Actions.BgpActions.SetLocalPerf) + } + if statement.Actions.BgpActions.SetNextHop != "" { + tmpStatement.Actions.BGPActions.SetNextHop = statement.Actions.BgpActions.SetNextHop + } + + } + + bgpPolicyConfig.Statement = append(bgpPolicyConfig.Statement, tmpStatement) + } + + tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + _, err := ApiHooks.NetGoBGPPolicyDefinitionAdd(&bgpPolicyConfig) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + +func ConfigDeleteBGPPolicyDefinitions(params operations.DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + var bgpPolicyConfig cmn.GoBGPPolicyDefinitionsMod + + // name + bgpPolicyConfig.Name = params.PolicyName + + tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + _, err := ApiHooks.NetGoBGPPolicyDefinitionDel(&bgpPolicyConfig) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + +func ConfigGetBGPPolicyDefinitions(params operations.GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + res, err := ApiHooks.NetGoBGPPolicyDefinitionsGet() + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + result := make([]*models.BGPPolicyDefinitionsMod, 0) + for _, df := range res { + tmpDf := models.BGPPolicyDefinitionsMod{} + tmpDf.Name = df.Name + for _, stat := range df.Statement { + tmpSt := models.BGPPolicyDefinitionsStatement{ + Name: stat.Name, + } + var BgpConditions models.BGPPolicyDefinitionsStatementConditionsBgpConditions + var MatchNeighborSet models.BGPPolicyDefinitionsStatementConditionsMatchNeighborSet + var MatchPrefixSet models.BGPPolicyDefinitionsStatementConditionsMatchPrefixSet + + MatchPrefixSet.PrefixSet = stat.Conditions.PrefixSet.PrefixSet + MatchPrefixSet.MatchSetOption = stat.Conditions.PrefixSet.MatchSetOption + + MatchNeighborSet.NeighborSet = stat.Conditions.NeighborSet.NeighborSet + MatchNeighborSet.MatchSetOption = stat.Conditions.NeighborSet.MatchSetOption + + BgpConditions.AfiSafiIn = stat.Conditions.BGPConditions.AfiSafiIn + + BgpConditions.AsPathLength = &models.BGPPolicyDefinitionsStatementConditionsBgpConditionsAsPathLength{ + Operator: stat.Conditions.BGPConditions.AsPathLength.Operator, + Value: int64(stat.Conditions.BGPConditions.AsPathLength.Value), + } + + BgpConditions.MatchAsPathSet = &models.BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchAsPathSet{ + AsPathSet: stat.Conditions.BGPConditions.AsPathSet.AsPathSet, + MatchSetOptions: stat.Conditions.BGPConditions.AsPathSet.MatchSetOptions, + } + + BgpConditions.MatchCommunitySet = &models.BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchCommunitySet{ + CommunitySet: stat.Conditions.BGPConditions.CommunitySet.CommunitySet, + MatchSetOptions: stat.Conditions.BGPConditions.CommunitySet.MatchSetOptions, + } + BgpConditions.MatchExtCommunitySet = &models.BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchExtCommunitySet{ + CommunitySet: stat.Conditions.BGPConditions.CommunitySet.CommunitySet, + MatchSetOptions: stat.Conditions.BGPConditions.CommunitySet.MatchSetOptions, + } + BgpConditions.MatchLargeCommunitySet = &models.BGPPolicyDefinitionsStatementConditionsBgpConditionsMatchLargeCommunitySet{ + CommunitySet: stat.Conditions.BGPConditions.CommunitySet.CommunitySet, + MatchSetOptions: stat.Conditions.BGPConditions.CommunitySet.MatchSetOptions, + } + + BgpConditions.NextHopInList = stat.Conditions.BGPConditions.NextHopInList + + BgpConditions.RouteType = stat.Conditions.BGPConditions.RouteType + + BgpConditions.Rpki = stat.Conditions.BGPConditions.Rpki + + Conditions := models.BGPPolicyDefinitionsStatementConditions{ + MatchPrefixSet: &MatchPrefixSet, + MatchNeighborSet: &MatchNeighborSet, + BgpConditions: &BgpConditions, + } + // action + var BgpActions models.BGPPolicyDefinitionsStatementActionsBgpActions + BgpActions.SetAsPathPrepend = &models.BGPPolicyDefinitionsStatementActionsBgpActionsSetAsPathPrepend{ + As: stat.Actions.BGPActions.SetAsPathPrepend.ASN, + RepeatN: int64(stat.Actions.BGPActions.SetAsPathPrepend.RepeatN), + } + BgpActions.SetCommunity = &models.BGPPolicyDefinitionsStatementActionsBgpActionsSetCommunity{ + Options: stat.Actions.BGPActions.SetCommunity.Options, + SetCommunityMethod: stat.Actions.BGPActions.SetCommunity.SetCommunityMethod, + } + BgpActions.SetExtCommunity = &models.BGPPolicyDefinitionsStatementActionsBgpActionsSetExtCommunity{ + Options: stat.Actions.BGPActions.SetExtCommunity.Options, + SetCommunityMethod: stat.Actions.BGPActions.SetExtCommunity.SetCommunityMethod, + } + BgpActions.SetLargeCommunity = &models.BGPPolicyDefinitionsStatementActionsBgpActionsSetLargeCommunity{ + Options: stat.Actions.BGPActions.SetLargeCommunity.Options, + SetCommunityMethod: stat.Actions.BGPActions.SetLargeCommunity.SetCommunityMethod, + } + BgpActions.SetLocalPerf = int64(stat.Actions.BGPActions.SetLocalPerf) + BgpActions.SetMed = stat.Actions.BGPActions.SetMed + BgpActions.SetNextHop = stat.Actions.BGPActions.SetNextHop + + Action := models.BGPPolicyDefinitionsStatementActions{ + BgpActions: &BgpActions, + RouteDisposition: stat.Actions.RouteDisposition, + } + tmpSt.Conditions = &Conditions + tmpSt.Actions = &Action + tmpDf.Statements = append(tmpDf.Statements, &tmpSt) + } + + result = append(result, &tmpDf) + } + + return operations.NewGetConfigBgpPolicyDefinitionsAllOK().WithPayload(&operations.GetConfigBgpPolicyDefinitionsAllOKBody{BgpPolicyAttr: result}) +} + +func ConfigPostBGPPolicyApply(params operations.PostConfigBgpPolicyApplyParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] BGP Policy Prefix %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + var bgpPolicyConfig cmn.GoBGPPolicyApply + + bgpPolicyConfig.NeighIPAddress = params.Attr.IPAddress + bgpPolicyConfig.PolicyType = params.Attr.PolicyType + bgpPolicyConfig.Polices = params.Attr.Policies + bgpPolicyConfig.RouteAction = params.Attr.RouteAction + tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + _, err := ApiHooks.NetGoBGPPolicyApplyAdd(&bgpPolicyConfig) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name.go b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name.go new file mode 100644 index 000000000..1414db5d4 --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc turns a function with the right signature into a delete config bgp policy definedsets defineset type type name handler +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc func(DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc) Handle(params DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + return fn(params) +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface for that can handle valid delete config bgp policy definedsets defineset type type name params +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface { + Handle(DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName creates a new http.Handler for the delete config bgp policy definedsets defineset type type name operation +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName(ctx *middleware.Context, handler DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName { + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName{Context: ctx, Handler: handler} +} + +/* + DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName swagger:route DELETE /config/bgp/policy/definedsets/{defineset_type}/{type_name} deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName + +# Delete a BGP definedsets + +Delete a BGP definedsets +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName struct { + Context *middleware.Context + Handler DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler +} + +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go new file mode 100644 index 000000000..0ec4642df --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams creates a new DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams object +// +// There are no default values defined in the spec. +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams { + + return DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams{} +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams contains all the bound params for the delete config bgp policy definedsets defineset type type name operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + Required: true + In: path + */ + DefinesetType string + /*type name + Required: true + In: path + */ + TypeName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() beforehand. +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDefinesetType, rhkDefinesetType, _ := route.Params.GetOK("defineset_type") + if err := o.bindDefinesetType(rDefinesetType, rhkDefinesetType, route.Formats); err != nil { + res = append(res, err) + } + + rTypeName, rhkTypeName, _ := route.Params.GetOK("type_name") + if err := o.bindTypeName(rTypeName, rhkTypeName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDefinesetType binds and validates parameter DefinesetType from path. +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindDefinesetType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.DefinesetType = raw + + return nil +} + +// bindTypeName binds and validates parameter TypeName from path. +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindTypeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.TypeName = raw + + return nil +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_responses.go b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_responses.go new file mode 100644 index 000000000..64056720b --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode int = 204 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent OK + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent struct { +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode int = 400 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest Malformed arguments for API call + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name bad request response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name bad request response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode int = 401 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized Invalid authentication credentials + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name unauthorized response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name unauthorized response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode int = 403 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden Capacity insufficient + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name forbidden response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name forbidden response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode int = 404 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound Resource not found + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name not found response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name not found response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode int = 409 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict Resource Conflict. Neigh already exists + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name conflict response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name conflict response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode int = 500 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError Internal service error + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name internal server error response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name internal server error response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +const DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode int = 503 + +/* +DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable Maintanence mode + +swagger:response deleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +*/ +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable creates DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable with default headers values +func NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable() *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + + return &DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable{} +} + +// WithPayload adds the payload to the delete config bgp policy definedsets defineset type type name service unavailable response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definedsets defineset type type name service unavailable response +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go new file mode 100644 index 000000000..f7aa5be1f --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL generates an URL for the delete config bgp policy definedsets defineset type type name operation +type DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL struct { + DefinesetType string + TypeName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) WithBasePath(bp string) *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definedsets/{defineset_type}/{type_name}" + + definesetType := o.DefinesetType + if definesetType != "" { + _path = strings.Replace(_path, "{defineset_type}", definesetType, -1) + } else { + return nil, errors.New("definesetType is required on DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + typeName := o.TypeName + if typeName != "" { + _path = strings.Replace(_path, "{type_name}", typeName, -1) + } else { + return nil, errors.New("typeName is required on DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name.go b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name.go new file mode 100644 index 000000000..935951db6 --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteConfigBgpPolicyDefinitionsPolicyNameHandlerFunc turns a function with the right signature into a delete config bgp policy definitions policy name handler +type DeleteConfigBgpPolicyDefinitionsPolicyNameHandlerFunc func(DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConfigBgpPolicyDefinitionsPolicyNameHandlerFunc) Handle(params DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder { + return fn(params) +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameHandler interface for that can handle valid delete config bgp policy definitions policy name params +type DeleteConfigBgpPolicyDefinitionsPolicyNameHandler interface { + Handle(DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyName creates a new http.Handler for the delete config bgp policy definitions policy name operation +func NewDeleteConfigBgpPolicyDefinitionsPolicyName(ctx *middleware.Context, handler DeleteConfigBgpPolicyDefinitionsPolicyNameHandler) *DeleteConfigBgpPolicyDefinitionsPolicyName { + return &DeleteConfigBgpPolicyDefinitionsPolicyName{Context: ctx, Handler: handler} +} + +/* + DeleteConfigBgpPolicyDefinitionsPolicyName swagger:route DELETE /config/bgp/policy/definitions/{policy_name} deleteConfigBgpPolicyDefinitionsPolicyName + +# Delete a BGP policy + +Delete a BGP Policy +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyName struct { + Context *middleware.Context + Handler DeleteConfigBgpPolicyDefinitionsPolicyNameHandler +} + +func (o *DeleteConfigBgpPolicyDefinitionsPolicyName) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConfigBgpPolicyDefinitionsPolicyNameParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_parameters.go b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_parameters.go new file mode 100644 index 000000000..beba88834 --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_parameters.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameParams creates a new DeleteConfigBgpPolicyDefinitionsPolicyNameParams object +// +// There are no default values defined in the spec. +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameParams() DeleteConfigBgpPolicyDefinitionsPolicyNameParams { + + return DeleteConfigBgpPolicyDefinitionsPolicyNameParams{} +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameParams contains all the bound params for the delete config bgp policy definitions policy name operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteConfigBgpPolicyDefinitionsPolicyName +type DeleteConfigBgpPolicyDefinitionsPolicyNameParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The name of the community + Required: true + In: path + */ + PolicyName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConfigBgpPolicyDefinitionsPolicyNameParams() beforehand. +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rPolicyName, rhkPolicyName, _ := route.Params.GetOK("policy_name") + if err := o.bindPolicyName(rPolicyName, rhkPolicyName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindPolicyName binds and validates parameter PolicyName from path. +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameParams) bindPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.PolicyName = raw + + return nil +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_responses.go b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_responses.go new file mode 100644 index 000000000..b727b06c1 --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// DeleteConfigBgpPolicyDefinitionsPolicyNameNoContentCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent +const DeleteConfigBgpPolicyDefinitionsPolicyNameNoContentCode int = 204 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent OK + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameNoContent +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent struct { +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameNoContent creates DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameNoContent() *DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequestCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest +const DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequestCode int = 400 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest Malformed arguments for API call + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameBadRequest +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest creates DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest() *DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name bad request response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name bad request response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorizedCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized +const DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorizedCode int = 401 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized Invalid authentication credentials + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized creates DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized() *DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name unauthorized response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name unauthorized response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameForbiddenCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden +const DeleteConfigBgpPolicyDefinitionsPolicyNameForbiddenCode int = 403 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden Capacity insufficient + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameForbidden +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameForbidden creates DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameForbidden() *DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name forbidden response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name forbidden response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameNotFoundCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound +const DeleteConfigBgpPolicyDefinitionsPolicyNameNotFoundCode int = 404 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound Resource not found + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameNotFound +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameNotFound creates DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameNotFound() *DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name not found response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name not found response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameConflictCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameConflict +const DeleteConfigBgpPolicyDefinitionsPolicyNameConflictCode int = 409 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameConflict Resource Conflict. Neigh already exists + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameConflict +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameConflict creates DeleteConfigBgpPolicyDefinitionsPolicyNameConflict with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameConflict() *DeleteConfigBgpPolicyDefinitionsPolicyNameConflict { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameConflict{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name conflict response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameConflict) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name conflict response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerErrorCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError +const DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerErrorCode int = 500 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError Internal service error + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError creates DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError() *DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name internal server error response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name internal server error response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailableCode is the HTTP code returned for type DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable +const DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailableCode int = 503 + +/* +DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable Maintanence mode + +swagger:response deleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable +*/ +type DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable creates DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable with default headers values +func NewDeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable() *DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable { + + return &DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable{} +} + +// WithPayload adds the payload to the delete config bgp policy definitions policy name service unavailable response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable) WithPayload(payload *models.Error) *DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config bgp policy definitions policy name service unavailable response +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_urlbuilder.go b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_urlbuilder.go new file mode 100644 index 000000000..767df8277 --- /dev/null +++ b/api/restapi/operations/delete_config_bgp_policy_definitions_policy_name_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteConfigBgpPolicyDefinitionsPolicyNameURL generates an URL for the delete config bgp policy definitions policy name operation +type DeleteConfigBgpPolicyDefinitionsPolicyNameURL struct { + PolicyName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) WithBasePath(bp string) *DeleteConfigBgpPolicyDefinitionsPolicyNameURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definitions/{policy_name}" + + policyName := o.PolicyName + if policyName != "" { + _path = strings.Replace(_path, "{policy_name}", policyName, -1) + } else { + return nil, errors.New("policyName is required on DeleteConfigBgpPolicyDefinitionsPolicyNameURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConfigBgpPolicyDefinitionsPolicyNameURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConfigBgpPolicyDefinitionsPolicyNameURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteConfigBgpPolicyDefinitionsPolicyNameURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name.go b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name.go new file mode 100644 index 000000000..0bb01bb6b --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/loxilb-io/loxilb/api/models" +) + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc turns a function with the right signature into a get config bgp policy definedsets defineset type type name handler +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc func(GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc) Handle(params GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + return fn(params) +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface for that can handle valid get config bgp policy definedsets defineset type type name params +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface { + Handle(GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName creates a new http.Handler for the get config bgp policy definedsets defineset type type name operation +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName(ctx *middleware.Context, handler GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName { + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName{Context: ctx, Handler: handler} +} + +/* + GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName swagger:route GET /config/bgp/policy/definedsets/{defineset_type}/{type_name} getConfigBgpPolicyDefinedsetsDefinesetTypeTypeName + +# Get the all of BGP definedsets + +Get the all of BGP, prefix/neighbor/community/extcommunity/aspath/largecommunity +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName struct { + Context *middleware.Context + Handler GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler +} + +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody get config bgp policy definedsets defineset type type name o k body +// +// swagger:model GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody struct { + + // definedsets attr + DefinedsetsAttr []*models.BGPPolicyDefinedSetGetEntry `json:"definedsetsAttr"` +} + +// Validate validates this get config bgp policy definedsets defineset type type name o k body +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDefinedsetsAttr(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) validateDefinedsetsAttr(formats strfmt.Registry) error { + if swag.IsZero(o.DefinedsetsAttr) { // not required + return nil + } + + for i := 0; i < len(o.DefinedsetsAttr); i++ { + if swag.IsZero(o.DefinedsetsAttr[i]) { // not required + continue + } + + if o.DefinedsetsAttr[i] != nil { + if err := o.DefinedsetsAttr[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK" + "." + "definedsetsAttr" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK" + "." + "definedsetsAttr" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get config bgp policy definedsets defineset type type name o k body based on the context it is used +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDefinedsetsAttr(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) contextValidateDefinedsetsAttr(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.DefinedsetsAttr); i++ { + + if o.DefinedsetsAttr[i] != nil { + if err := o.DefinedsetsAttr[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK" + "." + "definedsetsAttr" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK" + "." + "definedsetsAttr" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) UnmarshalBinary(b []byte) error { + var res GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go new file mode 100644 index 000000000..3b348ffc2 --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams creates a new GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams object +// +// There are no default values defined in the spec. +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams { + + return GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams{} +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams contains all the bound params for the get config bgp policy definedsets defineset type type name operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + Required: true + In: path + */ + DefinesetType string + /*type name + Required: true + In: path + */ + TypeName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() beforehand. +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDefinesetType, rhkDefinesetType, _ := route.Params.GetOK("defineset_type") + if err := o.bindDefinesetType(rDefinesetType, rhkDefinesetType, route.Formats); err != nil { + res = append(res, err) + } + + rTypeName, rhkTypeName, _ := route.Params.GetOK("type_name") + if err := o.bindTypeName(rTypeName, rhkTypeName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDefinesetType binds and validates parameter DefinesetType from path. +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindDefinesetType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.DefinesetType = raw + + return nil +} + +// bindTypeName binds and validates parameter TypeName from path. +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindTypeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.TypeName = raw + + return nil +} diff --git a/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_responses.go b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_responses.go new file mode 100644 index 000000000..15f507d97 --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_responses.go @@ -0,0 +1,399 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKCode int = 200 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK OK + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK struct { + + /* + In: Body + */ + Payload *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name o k response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK) WithPayload(payload *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name o k response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK) SetPayload(payload *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOKBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode int = 204 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent OK + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent struct { +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent{} +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode int = 400 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest Malformed arguments for API call + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name bad request response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name bad request response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode int = 401 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized Invalid authentication credentials + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name unauthorized response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name unauthorized response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode int = 403 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden Capacity insufficient + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name forbidden response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name forbidden response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode int = 404 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound Resource not found + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name not found response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name not found response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode int = 409 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict Resource Conflict. VLAN already exists OR dependency VRF/VNET not found + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name conflict response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name conflict response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode int = 500 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError Internal service error + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name internal server error response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name internal server error response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode is the HTTP code returned for type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +const GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode int = 503 + +/* +GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable Maintanence mode + +swagger:response getConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +*/ +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable creates GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable with default headers values +func NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable() *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + + return &GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable{} +} + +// WithPayload adds the payload to the get config bgp policy definedsets defineset type type name service unavailable response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definedsets defineset type type name service unavailable response +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go new file mode 100644 index 000000000..b94a78d9f --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL generates an URL for the get config bgp policy definedsets defineset type type name operation +type GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL struct { + DefinesetType string + TypeName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) WithBasePath(bp string) *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definedsets/{defineset_type}/{type_name}" + + definesetType := o.DefinesetType + if definesetType != "" { + _path = strings.Replace(_path, "{defineset_type}", definesetType, -1) + } else { + return nil, errors.New("definesetType is required on GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + typeName := o.TypeName + if typeName != "" { + _path = strings.Replace(_path, "{type_name}", typeName, -1) + } else { + return nil, errors.New("typeName is required on GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/get_config_bgp_policy_definitions_all.go b/api/restapi/operations/get_config_bgp_policy_definitions_all.go new file mode 100644 index 000000000..523340e53 --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definitions_all.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/loxilb-io/loxilb/api/models" +) + +// GetConfigBgpPolicyDefinitionsAllHandlerFunc turns a function with the right signature into a get config bgp policy definitions all handler +type GetConfigBgpPolicyDefinitionsAllHandlerFunc func(GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConfigBgpPolicyDefinitionsAllHandlerFunc) Handle(params GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder { + return fn(params) +} + +// GetConfigBgpPolicyDefinitionsAllHandler interface for that can handle valid get config bgp policy definitions all params +type GetConfigBgpPolicyDefinitionsAllHandler interface { + Handle(GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder +} + +// NewGetConfigBgpPolicyDefinitionsAll creates a new http.Handler for the get config bgp policy definitions all operation +func NewGetConfigBgpPolicyDefinitionsAll(ctx *middleware.Context, handler GetConfigBgpPolicyDefinitionsAllHandler) *GetConfigBgpPolicyDefinitionsAll { + return &GetConfigBgpPolicyDefinitionsAll{Context: ctx, Handler: handler} +} + +/* + GetConfigBgpPolicyDefinitionsAll swagger:route GET /config/bgp/policy/definitions/all getConfigBgpPolicyDefinitionsAll + +# Get BGP Policy definitions + +Get BGP Policy definitions +*/ +type GetConfigBgpPolicyDefinitionsAll struct { + Context *middleware.Context + Handler GetConfigBgpPolicyDefinitionsAllHandler +} + +func (o *GetConfigBgpPolicyDefinitionsAll) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConfigBgpPolicyDefinitionsAllParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// GetConfigBgpPolicyDefinitionsAllOKBody get config bgp policy definitions all o k body +// +// swagger:model GetConfigBgpPolicyDefinitionsAllOKBody +type GetConfigBgpPolicyDefinitionsAllOKBody struct { + + // bgp policy attr + BgpPolicyAttr []*models.BGPPolicyDefinitionsMod `json:"bgpPolicyAttr"` +} + +// Validate validates this get config bgp policy definitions all o k body +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateBgpPolicyAttr(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) validateBgpPolicyAttr(formats strfmt.Registry) error { + if swag.IsZero(o.BgpPolicyAttr) { // not required + return nil + } + + for i := 0; i < len(o.BgpPolicyAttr); i++ { + if swag.IsZero(o.BgpPolicyAttr[i]) { // not required + continue + } + + if o.BgpPolicyAttr[i] != nil { + if err := o.BgpPolicyAttr[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigBgpPolicyDefinitionsAllOK" + "." + "bgpPolicyAttr" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigBgpPolicyDefinitionsAllOK" + "." + "bgpPolicyAttr" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get config bgp policy definitions all o k body based on the context it is used +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateBgpPolicyAttr(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) contextValidateBgpPolicyAttr(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.BgpPolicyAttr); i++ { + + if o.BgpPolicyAttr[i] != nil { + if err := o.BgpPolicyAttr[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigBgpPolicyDefinitionsAllOK" + "." + "bgpPolicyAttr" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigBgpPolicyDefinitionsAllOK" + "." + "bgpPolicyAttr" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetConfigBgpPolicyDefinitionsAllOKBody) UnmarshalBinary(b []byte) error { + var res GetConfigBgpPolicyDefinitionsAllOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/restapi/operations/get_config_bgp_policy_definitions_all_parameters.go b/api/restapi/operations/get_config_bgp_policy_definitions_all_parameters.go new file mode 100644 index 000000000..ec7f87beb --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definitions_all_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetConfigBgpPolicyDefinitionsAllParams creates a new GetConfigBgpPolicyDefinitionsAllParams object +// +// There are no default values defined in the spec. +func NewGetConfigBgpPolicyDefinitionsAllParams() GetConfigBgpPolicyDefinitionsAllParams { + + return GetConfigBgpPolicyDefinitionsAllParams{} +} + +// GetConfigBgpPolicyDefinitionsAllParams contains all the bound params for the get config bgp policy definitions all operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetConfigBgpPolicyDefinitionsAll +type GetConfigBgpPolicyDefinitionsAllParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConfigBgpPolicyDefinitionsAllParams() beforehand. +func (o *GetConfigBgpPolicyDefinitionsAllParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/get_config_bgp_policy_definitions_all_responses.go b/api/restapi/operations/get_config_bgp_policy_definitions_all_responses.go new file mode 100644 index 000000000..a4ef1d6b0 --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definitions_all_responses.go @@ -0,0 +1,194 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// GetConfigBgpPolicyDefinitionsAllOKCode is the HTTP code returned for type GetConfigBgpPolicyDefinitionsAllOK +const GetConfigBgpPolicyDefinitionsAllOKCode int = 200 + +/* +GetConfigBgpPolicyDefinitionsAllOK OK + +swagger:response getConfigBgpPolicyDefinitionsAllOK +*/ +type GetConfigBgpPolicyDefinitionsAllOK struct { + + /* + In: Body + */ + Payload *GetConfigBgpPolicyDefinitionsAllOKBody `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinitionsAllOK creates GetConfigBgpPolicyDefinitionsAllOK with default headers values +func NewGetConfigBgpPolicyDefinitionsAllOK() *GetConfigBgpPolicyDefinitionsAllOK { + + return &GetConfigBgpPolicyDefinitionsAllOK{} +} + +// WithPayload adds the payload to the get config bgp policy definitions all o k response +func (o *GetConfigBgpPolicyDefinitionsAllOK) WithPayload(payload *GetConfigBgpPolicyDefinitionsAllOKBody) *GetConfigBgpPolicyDefinitionsAllOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definitions all o k response +func (o *GetConfigBgpPolicyDefinitionsAllOK) SetPayload(payload *GetConfigBgpPolicyDefinitionsAllOKBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinitionsAllOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinitionsAllUnauthorizedCode is the HTTP code returned for type GetConfigBgpPolicyDefinitionsAllUnauthorized +const GetConfigBgpPolicyDefinitionsAllUnauthorizedCode int = 401 + +/* +GetConfigBgpPolicyDefinitionsAllUnauthorized Invalid authentication credentials + +swagger:response getConfigBgpPolicyDefinitionsAllUnauthorized +*/ +type GetConfigBgpPolicyDefinitionsAllUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinitionsAllUnauthorized creates GetConfigBgpPolicyDefinitionsAllUnauthorized with default headers values +func NewGetConfigBgpPolicyDefinitionsAllUnauthorized() *GetConfigBgpPolicyDefinitionsAllUnauthorized { + + return &GetConfigBgpPolicyDefinitionsAllUnauthorized{} +} + +// WithPayload adds the payload to the get config bgp policy definitions all unauthorized response +func (o *GetConfigBgpPolicyDefinitionsAllUnauthorized) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinitionsAllUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definitions all unauthorized response +func (o *GetConfigBgpPolicyDefinitionsAllUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinitionsAllUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinitionsAllInternalServerErrorCode is the HTTP code returned for type GetConfigBgpPolicyDefinitionsAllInternalServerError +const GetConfigBgpPolicyDefinitionsAllInternalServerErrorCode int = 500 + +/* +GetConfigBgpPolicyDefinitionsAllInternalServerError Internal service error + +swagger:response getConfigBgpPolicyDefinitionsAllInternalServerError +*/ +type GetConfigBgpPolicyDefinitionsAllInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinitionsAllInternalServerError creates GetConfigBgpPolicyDefinitionsAllInternalServerError with default headers values +func NewGetConfigBgpPolicyDefinitionsAllInternalServerError() *GetConfigBgpPolicyDefinitionsAllInternalServerError { + + return &GetConfigBgpPolicyDefinitionsAllInternalServerError{} +} + +// WithPayload adds the payload to the get config bgp policy definitions all internal server error response +func (o *GetConfigBgpPolicyDefinitionsAllInternalServerError) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinitionsAllInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definitions all internal server error response +func (o *GetConfigBgpPolicyDefinitionsAllInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinitionsAllInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigBgpPolicyDefinitionsAllServiceUnavailableCode is the HTTP code returned for type GetConfigBgpPolicyDefinitionsAllServiceUnavailable +const GetConfigBgpPolicyDefinitionsAllServiceUnavailableCode int = 503 + +/* +GetConfigBgpPolicyDefinitionsAllServiceUnavailable Maintanence mode + +swagger:response getConfigBgpPolicyDefinitionsAllServiceUnavailable +*/ +type GetConfigBgpPolicyDefinitionsAllServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigBgpPolicyDefinitionsAllServiceUnavailable creates GetConfigBgpPolicyDefinitionsAllServiceUnavailable with default headers values +func NewGetConfigBgpPolicyDefinitionsAllServiceUnavailable() *GetConfigBgpPolicyDefinitionsAllServiceUnavailable { + + return &GetConfigBgpPolicyDefinitionsAllServiceUnavailable{} +} + +// WithPayload adds the payload to the get config bgp policy definitions all service unavailable response +func (o *GetConfigBgpPolicyDefinitionsAllServiceUnavailable) WithPayload(payload *models.Error) *GetConfigBgpPolicyDefinitionsAllServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config bgp policy definitions all service unavailable response +func (o *GetConfigBgpPolicyDefinitionsAllServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigBgpPolicyDefinitionsAllServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/get_config_bgp_policy_definitions_all_urlbuilder.go b/api/restapi/operations/get_config_bgp_policy_definitions_all_urlbuilder.go new file mode 100644 index 000000000..4dbefd6f3 --- /dev/null +++ b/api/restapi/operations/get_config_bgp_policy_definitions_all_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetConfigBgpPolicyDefinitionsAllURL generates an URL for the get config bgp policy definitions all operation +type GetConfigBgpPolicyDefinitionsAllURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigBgpPolicyDefinitionsAllURL) WithBasePath(bp string) *GetConfigBgpPolicyDefinitionsAllURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigBgpPolicyDefinitionsAllURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConfigBgpPolicyDefinitionsAllURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definitions/all" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConfigBgpPolicyDefinitionsAllURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConfigBgpPolicyDefinitionsAllURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConfigBgpPolicyDefinitionsAllURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConfigBgpPolicyDefinitionsAllURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConfigBgpPolicyDefinitionsAllURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConfigBgpPolicyDefinitionsAllURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/loxilb_rest_api_api.go b/api/restapi/operations/loxilb_rest_api_api.go index 86b40c15e..4c217c7ab 100644 --- a/api/restapi/operations/loxilb_rest_api_api.go +++ b/api/restapi/operations/loxilb_rest_api_api.go @@ -48,6 +48,12 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { DeleteConfigBgpNeighIPAddressHandler: DeleteConfigBgpNeighIPAddressHandlerFunc(func(params DeleteConfigBgpNeighIPAddressParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigBgpNeighIPAddress has not yet been implemented") }), + DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler: DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc(func(params DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + return middleware.NotImplemented("operation DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName has not yet been implemented") + }), + DeleteConfigBgpPolicyDefinitionsPolicyNameHandler: DeleteConfigBgpPolicyDefinitionsPolicyNameHandlerFunc(func(params DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder { + return middleware.NotImplemented("operation DeleteConfigBgpPolicyDefinitionsPolicyName has not yet been implemented") + }), DeleteConfigEndpointEpipaddressIPAddressHandler: DeleteConfigEndpointEpipaddressIPAddressHandlerFunc(func(params DeleteConfigEndpointEpipaddressIPAddressParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigEndpointEpipaddressIPAddress has not yet been implemented") }), @@ -102,6 +108,12 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { GetConfigBgpNeighAllHandler: GetConfigBgpNeighAllHandlerFunc(func(params GetConfigBgpNeighAllParams) middleware.Responder { return middleware.NotImplemented("operation GetConfigBgpNeighAll has not yet been implemented") }), + GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler: GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc(func(params GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + return middleware.NotImplemented("operation GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName has not yet been implemented") + }), + GetConfigBgpPolicyDefinitionsAllHandler: GetConfigBgpPolicyDefinitionsAllHandlerFunc(func(params GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder { + return middleware.NotImplemented("operation GetConfigBgpPolicyDefinitionsAll has not yet been implemented") + }), GetConfigCistateAllHandler: GetConfigCistateAllHandlerFunc(func(params GetConfigCistateAllParams) middleware.Responder { return middleware.NotImplemented("operation GetConfigCistateAll has not yet been implemented") }), @@ -174,6 +186,15 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { PostConfigBgpNeighHandler: PostConfigBgpNeighHandlerFunc(func(params PostConfigBgpNeighParams) middleware.Responder { return middleware.NotImplemented("operation PostConfigBgpNeigh has not yet been implemented") }), + PostConfigBgpPolicyApplyHandler: PostConfigBgpPolicyApplyHandlerFunc(func(params PostConfigBgpPolicyApplyParams) middleware.Responder { + return middleware.NotImplemented("operation PostConfigBgpPolicyApply has not yet been implemented") + }), + PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler: PostConfigBgpPolicyDefinedsetsDefinesetTypeHandlerFunc(func(params PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder { + return middleware.NotImplemented("operation PostConfigBgpPolicyDefinedsetsDefinesetType has not yet been implemented") + }), + PostConfigBgpPolicyDefinitionsHandler: PostConfigBgpPolicyDefinitionsHandlerFunc(func(params PostConfigBgpPolicyDefinitionsParams) middleware.Responder { + return middleware.NotImplemented("operation PostConfigBgpPolicyDefinitions has not yet been implemented") + }), PostConfigCistateHandler: PostConfigCistateHandlerFunc(func(params PostConfigCistateParams) middleware.Responder { return middleware.NotImplemented("operation PostConfigCistate has not yet been implemented") }), @@ -265,6 +286,10 @@ type LoxilbRestAPIAPI struct { DeleteConfigBfdRemoteIPRemoteIPHandler DeleteConfigBfdRemoteIPRemoteIPHandler // DeleteConfigBgpNeighIPAddressHandler sets the operation handler for the delete config bgp neigh IP address operation DeleteConfigBgpNeighIPAddressHandler DeleteConfigBgpNeighIPAddressHandler + // DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler sets the operation handler for the delete config bgp policy definedsets defineset type type name operation + DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler + // DeleteConfigBgpPolicyDefinitionsPolicyNameHandler sets the operation handler for the delete config bgp policy definitions policy name operation + DeleteConfigBgpPolicyDefinitionsPolicyNameHandler DeleteConfigBgpPolicyDefinitionsPolicyNameHandler // DeleteConfigEndpointEpipaddressIPAddressHandler sets the operation handler for the delete config endpoint epipaddress IP address operation DeleteConfigEndpointEpipaddressIPAddressHandler DeleteConfigEndpointEpipaddressIPAddressHandler // DeleteConfigFdbMacAddressDevIfNameHandler sets the operation handler for the delete config fdb mac address dev if name operation @@ -301,6 +326,10 @@ type LoxilbRestAPIAPI struct { GetConfigBfdAllHandler GetConfigBfdAllHandler // GetConfigBgpNeighAllHandler sets the operation handler for the get config bgp neigh all operation GetConfigBgpNeighAllHandler GetConfigBgpNeighAllHandler + // GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler sets the operation handler for the get config bgp policy definedsets defineset type type name operation + GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler + // GetConfigBgpPolicyDefinitionsAllHandler sets the operation handler for the get config bgp policy definitions all operation + GetConfigBgpPolicyDefinitionsAllHandler GetConfigBgpPolicyDefinitionsAllHandler // GetConfigCistateAllHandler sets the operation handler for the get config cistate all operation GetConfigCistateAllHandler GetConfigCistateAllHandler // GetConfigConntrackAllHandler sets the operation handler for the get config conntrack all operation @@ -349,6 +378,12 @@ type LoxilbRestAPIAPI struct { PostConfigBgpGlobalHandler PostConfigBgpGlobalHandler // PostConfigBgpNeighHandler sets the operation handler for the post config bgp neigh operation PostConfigBgpNeighHandler PostConfigBgpNeighHandler + // PostConfigBgpPolicyApplyHandler sets the operation handler for the post config bgp policy apply operation + PostConfigBgpPolicyApplyHandler PostConfigBgpPolicyApplyHandler + // PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler sets the operation handler for the post config bgp policy definedsets defineset type operation + PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler + // PostConfigBgpPolicyDefinitionsHandler sets the operation handler for the post config bgp policy definitions operation + PostConfigBgpPolicyDefinitionsHandler PostConfigBgpPolicyDefinitionsHandler // PostConfigCistateHandler sets the operation handler for the post config cistate operation PostConfigCistateHandler PostConfigCistateHandler // PostConfigEndpointHandler sets the operation handler for the post config endpoint operation @@ -466,6 +501,12 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.DeleteConfigBgpNeighIPAddressHandler == nil { unregistered = append(unregistered, "DeleteConfigBgpNeighIPAddressHandler") } + if o.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler == nil { + unregistered = append(unregistered, "DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler") + } + if o.DeleteConfigBgpPolicyDefinitionsPolicyNameHandler == nil { + unregistered = append(unregistered, "DeleteConfigBgpPolicyDefinitionsPolicyNameHandler") + } if o.DeleteConfigEndpointEpipaddressIPAddressHandler == nil { unregistered = append(unregistered, "DeleteConfigEndpointEpipaddressIPAddressHandler") } @@ -520,6 +561,12 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.GetConfigBgpNeighAllHandler == nil { unregistered = append(unregistered, "GetConfigBgpNeighAllHandler") } + if o.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler == nil { + unregistered = append(unregistered, "GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler") + } + if o.GetConfigBgpPolicyDefinitionsAllHandler == nil { + unregistered = append(unregistered, "GetConfigBgpPolicyDefinitionsAllHandler") + } if o.GetConfigCistateAllHandler == nil { unregistered = append(unregistered, "GetConfigCistateAllHandler") } @@ -592,6 +639,15 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.PostConfigBgpNeighHandler == nil { unregistered = append(unregistered, "PostConfigBgpNeighHandler") } + if o.PostConfigBgpPolicyApplyHandler == nil { + unregistered = append(unregistered, "PostConfigBgpPolicyApplyHandler") + } + if o.PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler == nil { + unregistered = append(unregistered, "PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler") + } + if o.PostConfigBgpPolicyDefinitionsHandler == nil { + unregistered = append(unregistered, "PostConfigBgpPolicyDefinitionsHandler") + } if o.PostConfigCistateHandler == nil { unregistered = append(unregistered, "PostConfigCistateHandler") } @@ -742,6 +798,14 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } + o.handlers["DELETE"]["/config/bgp/policy/definedsets/{defineset_type}/{type_name}"] = NewDeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeName(o.context, o.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/config/bgp/policy/definitions/{policy_name}"] = NewDeleteConfigBgpPolicyDefinitionsPolicyName(o.context, o.DeleteConfigBgpPolicyDefinitionsPolicyNameHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } o.handlers["DELETE"]["/config/endpoint/epipaddress/{ip_address}"] = NewDeleteConfigEndpointEpipaddressIPAddress(o.context, o.DeleteConfigEndpointEpipaddressIPAddressHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) @@ -814,6 +878,14 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/config/bgp/policy/definedsets/{defineset_type}/{type_name}"] = NewGetConfigBgpPolicyDefinedsetsDefinesetTypeTypeName(o.context, o.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/config/bgp/policy/definitions/all"] = NewGetConfigBgpPolicyDefinitionsAll(o.context, o.GetConfigBgpPolicyDefinitionsAllHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/config/cistate/all"] = NewGetConfigCistateAll(o.context, o.GetConfigCistateAllHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) @@ -910,6 +982,18 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/config/bgp/policy/apply"] = NewPostConfigBgpPolicyApply(o.context, o.PostConfigBgpPolicyApplyHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/config/bgp/policy/definedsets/{defineset_type}"] = NewPostConfigBgpPolicyDefinedsetsDefinesetType(o.context, o.PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/config/bgp/policy/definitions"] = NewPostConfigBgpPolicyDefinitions(o.context, o.PostConfigBgpPolicyDefinitionsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/config/cistate"] = NewPostConfigCistate(o.context, o.PostConfigCistateHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) diff --git a/api/restapi/operations/post_config_bgp_policy_apply.go b/api/restapi/operations/post_config_bgp_policy_apply.go new file mode 100644 index 000000000..4375d8707 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_apply.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostConfigBgpPolicyApplyHandlerFunc turns a function with the right signature into a post config bgp policy apply handler +type PostConfigBgpPolicyApplyHandlerFunc func(PostConfigBgpPolicyApplyParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostConfigBgpPolicyApplyHandlerFunc) Handle(params PostConfigBgpPolicyApplyParams) middleware.Responder { + return fn(params) +} + +// PostConfigBgpPolicyApplyHandler interface for that can handle valid post config bgp policy apply params +type PostConfigBgpPolicyApplyHandler interface { + Handle(PostConfigBgpPolicyApplyParams) middleware.Responder +} + +// NewPostConfigBgpPolicyApply creates a new http.Handler for the post config bgp policy apply operation +func NewPostConfigBgpPolicyApply(ctx *middleware.Context, handler PostConfigBgpPolicyApplyHandler) *PostConfigBgpPolicyApply { + return &PostConfigBgpPolicyApply{Context: ctx, Handler: handler} +} + +/* + PostConfigBgpPolicyApply swagger:route POST /config/bgp/policy/apply postConfigBgpPolicyApply + +# Apply BGP Policy in neighbor + +Apply BGP Policy in neighbor +*/ +type PostConfigBgpPolicyApply struct { + Context *middleware.Context + Handler PostConfigBgpPolicyApplyHandler +} + +func (o *PostConfigBgpPolicyApply) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostConfigBgpPolicyApplyParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/post_config_bgp_policy_apply_parameters.go b/api/restapi/operations/post_config_bgp_policy_apply_parameters.go new file mode 100644 index 000000000..dec0aef74 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_apply_parameters.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" + + "github.com/loxilb-io/loxilb/api/models" +) + +// NewPostConfigBgpPolicyApplyParams creates a new PostConfigBgpPolicyApplyParams object +// +// There are no default values defined in the spec. +func NewPostConfigBgpPolicyApplyParams() PostConfigBgpPolicyApplyParams { + + return PostConfigBgpPolicyApplyParams{} +} + +// PostConfigBgpPolicyApplyParams contains all the bound params for the post config bgp policy apply operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostConfigBgpPolicyApply +type PostConfigBgpPolicyApplyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Attributes of bgp neighbor + Required: true + In: body + */ + Attr *models.BGPApplyPolicyToNeighborMod +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostConfigBgpPolicyApplyParams() beforehand. +func (o *PostConfigBgpPolicyApplyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.BGPApplyPolicyToNeighborMod + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("attr", "body", "")) + } else { + res = append(res, errors.NewParseError("attr", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Attr = &body + } + } + } else { + res = append(res, errors.Required("attr", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/post_config_bgp_policy_apply_responses.go b/api/restapi/operations/post_config_bgp_policy_apply_responses.go new file mode 100644 index 000000000..8201dd909 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_apply_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// PostConfigBgpPolicyApplyNoContentCode is the HTTP code returned for type PostConfigBgpPolicyApplyNoContent +const PostConfigBgpPolicyApplyNoContentCode int = 204 + +/* +PostConfigBgpPolicyApplyNoContent OK + +swagger:response postConfigBgpPolicyApplyNoContent +*/ +type PostConfigBgpPolicyApplyNoContent struct { +} + +// NewPostConfigBgpPolicyApplyNoContent creates PostConfigBgpPolicyApplyNoContent with default headers values +func NewPostConfigBgpPolicyApplyNoContent() *PostConfigBgpPolicyApplyNoContent { + + return &PostConfigBgpPolicyApplyNoContent{} +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// PostConfigBgpPolicyApplyBadRequestCode is the HTTP code returned for type PostConfigBgpPolicyApplyBadRequest +const PostConfigBgpPolicyApplyBadRequestCode int = 400 + +/* +PostConfigBgpPolicyApplyBadRequest Malformed arguments for API call + +swagger:response postConfigBgpPolicyApplyBadRequest +*/ +type PostConfigBgpPolicyApplyBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyBadRequest creates PostConfigBgpPolicyApplyBadRequest with default headers values +func NewPostConfigBgpPolicyApplyBadRequest() *PostConfigBgpPolicyApplyBadRequest { + + return &PostConfigBgpPolicyApplyBadRequest{} +} + +// WithPayload adds the payload to the post config bgp policy apply bad request response +func (o *PostConfigBgpPolicyApplyBadRequest) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply bad request response +func (o *PostConfigBgpPolicyApplyBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyUnauthorizedCode is the HTTP code returned for type PostConfigBgpPolicyApplyUnauthorized +const PostConfigBgpPolicyApplyUnauthorizedCode int = 401 + +/* +PostConfigBgpPolicyApplyUnauthorized Invalid authentication credentials + +swagger:response postConfigBgpPolicyApplyUnauthorized +*/ +type PostConfigBgpPolicyApplyUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyUnauthorized creates PostConfigBgpPolicyApplyUnauthorized with default headers values +func NewPostConfigBgpPolicyApplyUnauthorized() *PostConfigBgpPolicyApplyUnauthorized { + + return &PostConfigBgpPolicyApplyUnauthorized{} +} + +// WithPayload adds the payload to the post config bgp policy apply unauthorized response +func (o *PostConfigBgpPolicyApplyUnauthorized) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply unauthorized response +func (o *PostConfigBgpPolicyApplyUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyForbiddenCode is the HTTP code returned for type PostConfigBgpPolicyApplyForbidden +const PostConfigBgpPolicyApplyForbiddenCode int = 403 + +/* +PostConfigBgpPolicyApplyForbidden Capacity insufficient + +swagger:response postConfigBgpPolicyApplyForbidden +*/ +type PostConfigBgpPolicyApplyForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyForbidden creates PostConfigBgpPolicyApplyForbidden with default headers values +func NewPostConfigBgpPolicyApplyForbidden() *PostConfigBgpPolicyApplyForbidden { + + return &PostConfigBgpPolicyApplyForbidden{} +} + +// WithPayload adds the payload to the post config bgp policy apply forbidden response +func (o *PostConfigBgpPolicyApplyForbidden) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply forbidden response +func (o *PostConfigBgpPolicyApplyForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyNotFoundCode is the HTTP code returned for type PostConfigBgpPolicyApplyNotFound +const PostConfigBgpPolicyApplyNotFoundCode int = 404 + +/* +PostConfigBgpPolicyApplyNotFound Resource not found + +swagger:response postConfigBgpPolicyApplyNotFound +*/ +type PostConfigBgpPolicyApplyNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyNotFound creates PostConfigBgpPolicyApplyNotFound with default headers values +func NewPostConfigBgpPolicyApplyNotFound() *PostConfigBgpPolicyApplyNotFound { + + return &PostConfigBgpPolicyApplyNotFound{} +} + +// WithPayload adds the payload to the post config bgp policy apply not found response +func (o *PostConfigBgpPolicyApplyNotFound) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply not found response +func (o *PostConfigBgpPolicyApplyNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyConflictCode is the HTTP code returned for type PostConfigBgpPolicyApplyConflict +const PostConfigBgpPolicyApplyConflictCode int = 409 + +/* +PostConfigBgpPolicyApplyConflict Resource Conflict. + +swagger:response postConfigBgpPolicyApplyConflict +*/ +type PostConfigBgpPolicyApplyConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyConflict creates PostConfigBgpPolicyApplyConflict with default headers values +func NewPostConfigBgpPolicyApplyConflict() *PostConfigBgpPolicyApplyConflict { + + return &PostConfigBgpPolicyApplyConflict{} +} + +// WithPayload adds the payload to the post config bgp policy apply conflict response +func (o *PostConfigBgpPolicyApplyConflict) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply conflict response +func (o *PostConfigBgpPolicyApplyConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyInternalServerErrorCode is the HTTP code returned for type PostConfigBgpPolicyApplyInternalServerError +const PostConfigBgpPolicyApplyInternalServerErrorCode int = 500 + +/* +PostConfigBgpPolicyApplyInternalServerError Internal service error + +swagger:response postConfigBgpPolicyApplyInternalServerError +*/ +type PostConfigBgpPolicyApplyInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyInternalServerError creates PostConfigBgpPolicyApplyInternalServerError with default headers values +func NewPostConfigBgpPolicyApplyInternalServerError() *PostConfigBgpPolicyApplyInternalServerError { + + return &PostConfigBgpPolicyApplyInternalServerError{} +} + +// WithPayload adds the payload to the post config bgp policy apply internal server error response +func (o *PostConfigBgpPolicyApplyInternalServerError) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply internal server error response +func (o *PostConfigBgpPolicyApplyInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyApplyServiceUnavailableCode is the HTTP code returned for type PostConfigBgpPolicyApplyServiceUnavailable +const PostConfigBgpPolicyApplyServiceUnavailableCode int = 503 + +/* +PostConfigBgpPolicyApplyServiceUnavailable Maintanence mode + +swagger:response postConfigBgpPolicyApplyServiceUnavailable +*/ +type PostConfigBgpPolicyApplyServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyApplyServiceUnavailable creates PostConfigBgpPolicyApplyServiceUnavailable with default headers values +func NewPostConfigBgpPolicyApplyServiceUnavailable() *PostConfigBgpPolicyApplyServiceUnavailable { + + return &PostConfigBgpPolicyApplyServiceUnavailable{} +} + +// WithPayload adds the payload to the post config bgp policy apply service unavailable response +func (o *PostConfigBgpPolicyApplyServiceUnavailable) WithPayload(payload *models.Error) *PostConfigBgpPolicyApplyServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy apply service unavailable response +func (o *PostConfigBgpPolicyApplyServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyApplyServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/post_config_bgp_policy_apply_urlbuilder.go b/api/restapi/operations/post_config_bgp_policy_apply_urlbuilder.go new file mode 100644 index 000000000..05bea9319 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_apply_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PostConfigBgpPolicyApplyURL generates an URL for the post config bgp policy apply operation +type PostConfigBgpPolicyApplyURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyApplyURL) WithBasePath(bp string) *PostConfigBgpPolicyApplyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyApplyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostConfigBgpPolicyApplyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/apply" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostConfigBgpPolicyApplyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostConfigBgpPolicyApplyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostConfigBgpPolicyApplyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostConfigBgpPolicyApplyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostConfigBgpPolicyApplyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostConfigBgpPolicyApplyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type.go new file mode 100644 index 000000000..70544a462 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeHandlerFunc turns a function with the right signature into a post config bgp policy definedsets defineset type handler +type PostConfigBgpPolicyDefinedsetsDefinesetTypeHandlerFunc func(PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostConfigBgpPolicyDefinedsetsDefinesetTypeHandlerFunc) Handle(params PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder { + return fn(params) +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler interface for that can handle valid post config bgp policy definedsets defineset type params +type PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler interface { + Handle(PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetType creates a new http.Handler for the post config bgp policy definedsets defineset type operation +func NewPostConfigBgpPolicyDefinedsetsDefinesetType(ctx *middleware.Context, handler PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler) *PostConfigBgpPolicyDefinedsetsDefinesetType { + return &PostConfigBgpPolicyDefinedsetsDefinesetType{Context: ctx, Handler: handler} +} + +/* + PostConfigBgpPolicyDefinedsetsDefinesetType swagger:route POST /config/bgp/policy/definedsets/{defineset_type} postConfigBgpPolicyDefinedsetsDefinesetType + +# Adds a BGP definedsets for making Policy + +Adds a BGP definedsets for making Policy +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetType struct { + Context *middleware.Context + Handler PostConfigBgpPolicyDefinedsetsDefinesetTypeHandler +} + +func (o *PostConfigBgpPolicyDefinedsetsDefinesetType) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostConfigBgpPolicyDefinedsetsDefinesetTypeParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_parameters.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_parameters.go new file mode 100644 index 000000000..ba48aa3ad --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_parameters.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/loxilb-io/loxilb/api/models" +) + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeParams creates a new PostConfigBgpPolicyDefinedsetsDefinesetTypeParams object +// +// There are no default values defined in the spec. +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeParams() PostConfigBgpPolicyDefinedsetsDefinesetTypeParams { + + return PostConfigBgpPolicyDefinedsetsDefinesetTypeParams{} +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeParams contains all the bound params for the post config bgp policy definedsets defineset type operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostConfigBgpPolicyDefinedsetsDefinesetType +type PostConfigBgpPolicyDefinedsetsDefinesetTypeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Attributes of bgp neighbor + Required: true + In: body + */ + Attr *models.BGPPolicyDefinedSetsMod + /*defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + Required: true + In: path + */ + DefinesetType string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostConfigBgpPolicyDefinedsetsDefinesetTypeParams() beforehand. +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.BGPPolicyDefinedSetsMod + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("attr", "body", "")) + } else { + res = append(res, errors.NewParseError("attr", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Attr = &body + } + } + } else { + res = append(res, errors.Required("attr", "body", "")) + } + + rDefinesetType, rhkDefinesetType, _ := route.Params.GetOK("defineset_type") + if err := o.bindDefinesetType(rDefinesetType, rhkDefinesetType, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDefinesetType binds and validates parameter DefinesetType from path. +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) bindDefinesetType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.DefinesetType = raw + + return nil +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_responses.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_responses.go new file mode 100644 index 000000000..4c6f0e016 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContentCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent +const PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContentCode int = 204 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent OK + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeNoContent +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent struct { +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent creates PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent() *PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent{} +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequestCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest +const PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequestCode int = 400 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest Malformed arguments for API call + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest creates PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest() *PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type bad request response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type bad request response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorizedCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized +const PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorizedCode int = 401 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized Invalid authentication credentials + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized creates PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized() *PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type unauthorized response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type unauthorized response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeForbiddenCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden +const PostConfigBgpPolicyDefinedsetsDefinesetTypeForbiddenCode int = 403 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden Capacity insufficient + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeForbidden +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden creates PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden() *PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type forbidden response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type forbidden response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFoundCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound +const PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFoundCode int = 404 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound Resource not found + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeNotFound +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound creates PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound() *PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type not found response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type not found response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeConflictCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict +const PostConfigBgpPolicyDefinedsetsDefinesetTypeConflictCode int = 409 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict Resource Conflict. + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeConflict +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeConflict creates PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeConflict() *PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type conflict response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type conflict response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerErrorCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError +const PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerErrorCode int = 500 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError Internal service error + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError creates PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError() *PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type internal server error response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type internal server error response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailableCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable +const PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailableCode int = 503 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable Maintanence mode + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable creates PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable() *PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type service unavailable response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type service unavailable response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name.go new file mode 100644 index 000000000..f95a689e2 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc turns a function with the right signature into a post config bgp policy definedsets defineset type type name handler +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc func(PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandlerFunc) Handle(params PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { + return fn(params) +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface for that can handle valid post config bgp policy definedsets defineset type type name params +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler interface { + Handle(PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName creates a new http.Handler for the post config bgp policy definedsets defineset type type name operation +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName(ctx *middleware.Context, handler PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName { + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName{Context: ctx, Handler: handler} +} + +/* + PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName swagger:route POST /config/bgp/policy/definedsets/{defineset_type}/{type_name} postConfigBgpPolicyDefinedsetsDefinesetTypeTypeName + +# Adds a BGP BGP definedsets for making Policy + +Adds a BGP definedsets for making Policy +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName struct { + Context *middleware.Context + Handler PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameHandler +} + +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go new file mode 100644 index 000000000..9cc6c3830 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_parameters.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/loxilb-io/loxilb/api/models" +) + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams creates a new PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams object +// +// There are no default values defined in the spec. +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams { + + return PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams{} +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams contains all the bound params for the post config bgp policy definedsets defineset type type name operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeName +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Attributes of bgp neighbor + Required: true + In: body + */ + Attr *models.BGPPolicyPrefixMod + /*defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + Required: true + In: path + */ + DefinesetType string + /*type name + Required: true + In: path + */ + TypeName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams() beforehand. +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.BGPPolicyPrefixMod + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("attr", "body", "")) + } else { + res = append(res, errors.NewParseError("attr", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Attr = &body + } + } + } else { + res = append(res, errors.Required("attr", "body", "")) + } + + rDefinesetType, rhkDefinesetType, _ := route.Params.GetOK("defineset_type") + if err := o.bindDefinesetType(rDefinesetType, rhkDefinesetType, route.Formats); err != nil { + res = append(res, err) + } + + rTypeName, rhkTypeName, _ := route.Params.GetOK("type_name") + if err := o.bindTypeName(rTypeName, rhkTypeName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDefinesetType binds and validates parameter DefinesetType from path. +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindDefinesetType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.DefinesetType = raw + + return nil +} + +// bindTypeName binds and validates parameter TypeName from path. +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) bindTypeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.TypeName = raw + + return nil +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_responses.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_responses.go new file mode 100644 index 000000000..26a985f05 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContentCode int = 204 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent OK + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent struct { +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent{} +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequestCode int = 400 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest Malformed arguments for API call + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name bad request response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name bad request response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorizedCode int = 401 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized Invalid authentication credentials + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name unauthorized response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name unauthorized response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbiddenCode int = 403 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden Capacity insufficient + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name forbidden response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name forbidden response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFoundCode int = 404 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound Resource not found + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name not found response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name not found response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflictCode int = 409 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict Resource Conflict. + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name conflict response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name conflict response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerErrorCode int = 500 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError Internal service error + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name internal server error response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name internal server error response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode is the HTTP code returned for type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +const PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailableCode int = 503 + +/* +PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable Maintanence mode + +swagger:response postConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable +*/ +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable creates PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable with default headers values +func NewPostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable() *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + + return &PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable{} +} + +// WithPayload adds the payload to the post config bgp policy definedsets defineset type type name service unavailable response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definedsets defineset type type name service unavailable response +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go new file mode 100644 index 000000000..39881abd7 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_type_name_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL generates an URL for the post config bgp policy definedsets defineset type type name operation +type PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL struct { + DefinesetType string + TypeName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) WithBasePath(bp string) *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definedsets/{defineset_type}/{type_name}" + + definesetType := o.DefinesetType + if definesetType != "" { + _path = strings.Replace(_path, "{defineset_type}", definesetType, -1) + } else { + return nil, errors.New("definesetType is required on PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + typeName := o.TypeName + if typeName != "" { + _path = strings.Replace(_path, "{type_name}", typeName, -1) + } else { + return nil, errors.New("typeName is required on PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_urlbuilder.go b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_urlbuilder.go new file mode 100644 index 000000000..6fe820d14 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definedsets_defineset_type_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PostConfigBgpPolicyDefinedsetsDefinesetTypeURL generates an URL for the post config bgp policy definedsets defineset type operation +type PostConfigBgpPolicyDefinedsetsDefinesetTypeURL struct { + DefinesetType string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) WithBasePath(bp string) *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definedsets/{defineset_type}" + + definesetType := o.DefinesetType + if definesetType != "" { + _path = strings.Replace(_path, "{defineset_type}", definesetType, -1) + } else { + return nil, errors.New("definesetType is required on PostConfigBgpPolicyDefinedsetsDefinesetTypeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostConfigBgpPolicyDefinedsetsDefinesetTypeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostConfigBgpPolicyDefinedsetsDefinesetTypeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostConfigBgpPolicyDefinedsetsDefinesetTypeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/post_config_bgp_policy_definitions.go b/api/restapi/operations/post_config_bgp_policy_definitions.go new file mode 100644 index 000000000..1816fba4c --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definitions.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostConfigBgpPolicyDefinitionsHandlerFunc turns a function with the right signature into a post config bgp policy definitions handler +type PostConfigBgpPolicyDefinitionsHandlerFunc func(PostConfigBgpPolicyDefinitionsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostConfigBgpPolicyDefinitionsHandlerFunc) Handle(params PostConfigBgpPolicyDefinitionsParams) middleware.Responder { + return fn(params) +} + +// PostConfigBgpPolicyDefinitionsHandler interface for that can handle valid post config bgp policy definitions params +type PostConfigBgpPolicyDefinitionsHandler interface { + Handle(PostConfigBgpPolicyDefinitionsParams) middleware.Responder +} + +// NewPostConfigBgpPolicyDefinitions creates a new http.Handler for the post config bgp policy definitions operation +func NewPostConfigBgpPolicyDefinitions(ctx *middleware.Context, handler PostConfigBgpPolicyDefinitionsHandler) *PostConfigBgpPolicyDefinitions { + return &PostConfigBgpPolicyDefinitions{Context: ctx, Handler: handler} +} + +/* + PostConfigBgpPolicyDefinitions swagger:route POST /config/bgp/policy/definitions postConfigBgpPolicyDefinitions + +# Adds a BGP Policy + +Adds a BGP Policy +*/ +type PostConfigBgpPolicyDefinitions struct { + Context *middleware.Context + Handler PostConfigBgpPolicyDefinitionsHandler +} + +func (o *PostConfigBgpPolicyDefinitions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostConfigBgpPolicyDefinitionsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/post_config_bgp_policy_definitions_parameters.go b/api/restapi/operations/post_config_bgp_policy_definitions_parameters.go new file mode 100644 index 000000000..9e1cd97ba --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definitions_parameters.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" + + "github.com/loxilb-io/loxilb/api/models" +) + +// NewPostConfigBgpPolicyDefinitionsParams creates a new PostConfigBgpPolicyDefinitionsParams object +// +// There are no default values defined in the spec. +func NewPostConfigBgpPolicyDefinitionsParams() PostConfigBgpPolicyDefinitionsParams { + + return PostConfigBgpPolicyDefinitionsParams{} +} + +// PostConfigBgpPolicyDefinitionsParams contains all the bound params for the post config bgp policy definitions operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostConfigBgpPolicyDefinitions +type PostConfigBgpPolicyDefinitionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Attributes of bgp neighbor + Required: true + In: body + */ + Attr *models.BGPPolicyDefinitionsMod +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostConfigBgpPolicyDefinitionsParams() beforehand. +func (o *PostConfigBgpPolicyDefinitionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.BGPPolicyDefinitionsMod + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("attr", "body", "")) + } else { + res = append(res, errors.NewParseError("attr", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Attr = &body + } + } + } else { + res = append(res, errors.Required("attr", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/post_config_bgp_policy_definitions_responses.go b/api/restapi/operations/post_config_bgp_policy_definitions_responses.go new file mode 100644 index 000000000..ceee17ba0 --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definitions_responses.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/loxilb-io/loxilb/api/models" +) + +// PostConfigBgpPolicyDefinitionsNoContentCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsNoContent +const PostConfigBgpPolicyDefinitionsNoContentCode int = 204 + +/* +PostConfigBgpPolicyDefinitionsNoContent OK + +swagger:response postConfigBgpPolicyDefinitionsNoContent +*/ +type PostConfigBgpPolicyDefinitionsNoContent struct { +} + +// NewPostConfigBgpPolicyDefinitionsNoContent creates PostConfigBgpPolicyDefinitionsNoContent with default headers values +func NewPostConfigBgpPolicyDefinitionsNoContent() *PostConfigBgpPolicyDefinitionsNoContent { + + return &PostConfigBgpPolicyDefinitionsNoContent{} +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// PostConfigBgpPolicyDefinitionsBadRequestCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsBadRequest +const PostConfigBgpPolicyDefinitionsBadRequestCode int = 400 + +/* +PostConfigBgpPolicyDefinitionsBadRequest Malformed arguments for API call + +swagger:response postConfigBgpPolicyDefinitionsBadRequest +*/ +type PostConfigBgpPolicyDefinitionsBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsBadRequest creates PostConfigBgpPolicyDefinitionsBadRequest with default headers values +func NewPostConfigBgpPolicyDefinitionsBadRequest() *PostConfigBgpPolicyDefinitionsBadRequest { + + return &PostConfigBgpPolicyDefinitionsBadRequest{} +} + +// WithPayload adds the payload to the post config bgp policy definitions bad request response +func (o *PostConfigBgpPolicyDefinitionsBadRequest) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions bad request response +func (o *PostConfigBgpPolicyDefinitionsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsUnauthorizedCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsUnauthorized +const PostConfigBgpPolicyDefinitionsUnauthorizedCode int = 401 + +/* +PostConfigBgpPolicyDefinitionsUnauthorized Invalid authentication credentials + +swagger:response postConfigBgpPolicyDefinitionsUnauthorized +*/ +type PostConfigBgpPolicyDefinitionsUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsUnauthorized creates PostConfigBgpPolicyDefinitionsUnauthorized with default headers values +func NewPostConfigBgpPolicyDefinitionsUnauthorized() *PostConfigBgpPolicyDefinitionsUnauthorized { + + return &PostConfigBgpPolicyDefinitionsUnauthorized{} +} + +// WithPayload adds the payload to the post config bgp policy definitions unauthorized response +func (o *PostConfigBgpPolicyDefinitionsUnauthorized) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions unauthorized response +func (o *PostConfigBgpPolicyDefinitionsUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsForbiddenCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsForbidden +const PostConfigBgpPolicyDefinitionsForbiddenCode int = 403 + +/* +PostConfigBgpPolicyDefinitionsForbidden Capacity insufficient + +swagger:response postConfigBgpPolicyDefinitionsForbidden +*/ +type PostConfigBgpPolicyDefinitionsForbidden struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsForbidden creates PostConfigBgpPolicyDefinitionsForbidden with default headers values +func NewPostConfigBgpPolicyDefinitionsForbidden() *PostConfigBgpPolicyDefinitionsForbidden { + + return &PostConfigBgpPolicyDefinitionsForbidden{} +} + +// WithPayload adds the payload to the post config bgp policy definitions forbidden response +func (o *PostConfigBgpPolicyDefinitionsForbidden) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions forbidden response +func (o *PostConfigBgpPolicyDefinitionsForbidden) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsNotFoundCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsNotFound +const PostConfigBgpPolicyDefinitionsNotFoundCode int = 404 + +/* +PostConfigBgpPolicyDefinitionsNotFound Resource not found + +swagger:response postConfigBgpPolicyDefinitionsNotFound +*/ +type PostConfigBgpPolicyDefinitionsNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsNotFound creates PostConfigBgpPolicyDefinitionsNotFound with default headers values +func NewPostConfigBgpPolicyDefinitionsNotFound() *PostConfigBgpPolicyDefinitionsNotFound { + + return &PostConfigBgpPolicyDefinitionsNotFound{} +} + +// WithPayload adds the payload to the post config bgp policy definitions not found response +func (o *PostConfigBgpPolicyDefinitionsNotFound) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions not found response +func (o *PostConfigBgpPolicyDefinitionsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsConflictCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsConflict +const PostConfigBgpPolicyDefinitionsConflictCode int = 409 + +/* +PostConfigBgpPolicyDefinitionsConflict Resource Conflict. + +swagger:response postConfigBgpPolicyDefinitionsConflict +*/ +type PostConfigBgpPolicyDefinitionsConflict struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsConflict creates PostConfigBgpPolicyDefinitionsConflict with default headers values +func NewPostConfigBgpPolicyDefinitionsConflict() *PostConfigBgpPolicyDefinitionsConflict { + + return &PostConfigBgpPolicyDefinitionsConflict{} +} + +// WithPayload adds the payload to the post config bgp policy definitions conflict response +func (o *PostConfigBgpPolicyDefinitionsConflict) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions conflict response +func (o *PostConfigBgpPolicyDefinitionsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsInternalServerErrorCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsInternalServerError +const PostConfigBgpPolicyDefinitionsInternalServerErrorCode int = 500 + +/* +PostConfigBgpPolicyDefinitionsInternalServerError Internal service error + +swagger:response postConfigBgpPolicyDefinitionsInternalServerError +*/ +type PostConfigBgpPolicyDefinitionsInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsInternalServerError creates PostConfigBgpPolicyDefinitionsInternalServerError with default headers values +func NewPostConfigBgpPolicyDefinitionsInternalServerError() *PostConfigBgpPolicyDefinitionsInternalServerError { + + return &PostConfigBgpPolicyDefinitionsInternalServerError{} +} + +// WithPayload adds the payload to the post config bgp policy definitions internal server error response +func (o *PostConfigBgpPolicyDefinitionsInternalServerError) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions internal server error response +func (o *PostConfigBgpPolicyDefinitionsInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigBgpPolicyDefinitionsServiceUnavailableCode is the HTTP code returned for type PostConfigBgpPolicyDefinitionsServiceUnavailable +const PostConfigBgpPolicyDefinitionsServiceUnavailableCode int = 503 + +/* +PostConfigBgpPolicyDefinitionsServiceUnavailable Maintanence mode + +swagger:response postConfigBgpPolicyDefinitionsServiceUnavailable +*/ +type PostConfigBgpPolicyDefinitionsServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigBgpPolicyDefinitionsServiceUnavailable creates PostConfigBgpPolicyDefinitionsServiceUnavailable with default headers values +func NewPostConfigBgpPolicyDefinitionsServiceUnavailable() *PostConfigBgpPolicyDefinitionsServiceUnavailable { + + return &PostConfigBgpPolicyDefinitionsServiceUnavailable{} +} + +// WithPayload adds the payload to the post config bgp policy definitions service unavailable response +func (o *PostConfigBgpPolicyDefinitionsServiceUnavailable) WithPayload(payload *models.Error) *PostConfigBgpPolicyDefinitionsServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config bgp policy definitions service unavailable response +func (o *PostConfigBgpPolicyDefinitionsServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigBgpPolicyDefinitionsServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/post_config_bgp_policy_definitions_urlbuilder.go b/api/restapi/operations/post_config_bgp_policy_definitions_urlbuilder.go new file mode 100644 index 000000000..600c875dc --- /dev/null +++ b/api/restapi/operations/post_config_bgp_policy_definitions_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PostConfigBgpPolicyDefinitionsURL generates an URL for the post config bgp policy definitions operation +type PostConfigBgpPolicyDefinitionsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinitionsURL) WithBasePath(bp string) *PostConfigBgpPolicyDefinitionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigBgpPolicyDefinitionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostConfigBgpPolicyDefinitionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/bgp/policy/definitions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostConfigBgpPolicyDefinitionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostConfigBgpPolicyDefinitionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostConfigBgpPolicyDefinitionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostConfigBgpPolicyDefinitionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostConfigBgpPolicyDefinitionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostConfigBgpPolicyDefinitionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/server.go b/api/restapi/server.go index c61df9e24..105444517 100644 --- a/api/restapi/server.go +++ b/api/restapi/server.go @@ -3,12 +3,12 @@ package restapi import ( + "github.com/loxilb-io/loxilb/options" "context" "crypto/tls" "crypto/x509" "errors" "fmt" - "github.com/loxilb-io/loxilb/options" "log" "net" "net/http" diff --git a/api/swagger.yml b/api/swagger.yml index afa200b84..3c0f16566 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2235,6 +2235,313 @@ paths: schema: $ref: '#/definitions/Error' + + '/config/bgp/policy/definedsets/{defineset_type}/{type_name}': + get: + summary: Get the all of BGP definedsets + description: Get the all of BGP, prefix/neighbor/community/extcommunity/aspath/largecommunity + parameters: + - name: defineset_type + in: path + type: string + required: true + description: defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + - name: type_name + in: path + type: string + required: true + description: type name + responses: + '200': + description: OK + schema: + type: object + properties: + definedsetsAttr: + type: array + items: + $ref: '#/definitions/BGPPolicyDefinedSetGetEntry' + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. VLAN already exists OR dependency VRF/VNET not found + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + delete: + summary: Delete a BGP definedsets + description: Delete a BGP definedsets + parameters: + - name: defineset_type + in: path + type: string + required: true + description: defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + - name: type_name + in: path + type: string + required: true + description: type name + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. Neigh already exists + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + '/config/bgp/policy/definedsets/{defineset_type}': + post: + summary: Adds a BGP definedsets for making Policy + description: Adds a BGP definedsets for making Policy + parameters: + - name: defineset_type + in: path + type: string + required: true + description: defineset type one of prefix/neighbor/community/extcommunity/aspath/largecommunity + - name: attr + in: body + required: true + description: Attributes of bgp neighbor + schema: + $ref: '#/definitions/BGPPolicyDefinedSetsMod' + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + '/config/bgp/policy/definitions/all': + get: + summary: Get BGP Policy definitions + description: Get BGP Policy definitions + responses: + '200': + description: OK + schema: + type: object + properties: + bgpPolicyAttr: + type: array + items: + $ref: '#/definitions/BGPPolicyDefinitionsMod' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + '/config/bgp/policy/definitions': + post: + summary: Adds a BGP Policy + description: Adds a BGP Policy + parameters: + - name: attr + in: body + required: true + description: Attributes of bgp neighbor + schema: + $ref: '#/definitions/BGPPolicyDefinitionsMod' + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + '/config/bgp/policy/definitions/{policy_name}': + delete: + summary: Delete a BGP policy + description: Delete a BGP Policy + parameters: + - name: policy_name + in: path + type: string + required: true + description: The name of the community + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. Neigh already exists + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + + '/config/bgp/policy/apply': + post: + summary: Apply BGP Policy in neighbor + description: Apply BGP Policy in neighbor + parameters: + - name: attr + in: body + required: true + description: Attributes of bgp neighbor + schema: + $ref: '#/definitions/BGPApplyPolicyToNeighborMod' + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' + + '/config/bgp/global': post: summary: Adds a BGP global config @@ -3282,7 +3589,193 @@ definitions: type: boolean description: Enable multi-hop peering (if needed) + BGPPolicyDefinedSetGetEntry: + type: object + properties: + name: + type: string + description: BGP Defined set Entries + prefixList: + type: array + items: + $ref: '#/definitions/BGPPolicyPrefix' + list: + type: array + items: + type: string + + BGPPolicyDefinedSetsMod: + type: object + properties: + name: + type: string + description: BGP Neighbor IP address + List: + type: array + items: + type: string + prefixList: + type: array + items: + $ref: '#/definitions/BGPPolicyPrefix' + + BGPPolicyPrefix: + type: object + properties: + ipPrefix: + type: string + description: BGP Neighbor IP address + masklengthRange: + type: string + description: Remote AS number + + BGPPolicyDefinitionsMod: + type: object + properties: + name: + type: string + description: BGP Neighbor IP address + statements: + type: array + items: + $ref: '#/definitions/BGPPolicyDefinitionsStatement' + BGPPolicyDefinitionsStatement: + type: object + properties: + name: + type: string + conditions: + type: object + properties: + bgpConditions: + type: object + properties: + afiSafiIn: + type: array + items: + type: string + asPathLength: + type: object + properties: + operator: + type: string + value: + type: integer + matchAsPathSet: + type: object + properties: + asPathSet: + type: string + matchSetOptions: + type: string + matchCommunitySet: + type: object + properties: + communitySet: + type: string + matchSetOptions: + type: string + matchExtCommunitySet: + type: object + properties: + communitySet: + type: string + matchSetOptions: + type: string + matchLargeCommunitySet: + type: object + properties: + communitySet: + type: string + matchSetOptions: + type: string + nextHopInList: + type: array + items: + type: string + rpki: + type: string + routeType: + type: string + matchNeighborSet: + type: object + properties: + matchSetOption: + type: string + neighborSet: + type: string + matchPrefixSet: + type: object + properties: + matchSetOption: + type: string + prefixSet: + type: string + actions: + type: object + properties: + routeDisposition: + type: string + bgpActions: + type: object + properties: + setMed: + type: string + setNextHop: + type: string + setLocalPerf: + type: integer + setCommunity: + type: object + properties: + options: + type: string + setCommunityMethod: + type: array + items: + type: string + setExtCommunity: + type: object + properties: + options: + type: string + setCommunityMethod: + type: array + items: + type: string + setLargeCommunity: + type: object + properties: + options: + type: string + setCommunityMethod: + type: array + items: + type: string + setAsPathPrepend: + type: object + properties: + as: + type: string + repeatN: + type: integer + + BGPApplyPolicyToNeighborMod: + type: object + properties: + ipAddress: + type: string + description: BGP Neighbor IP address + policyType: + type: string + policies: + type: array + items: + type: string + routeAction: + type: string + BGPNeighGetEntry: type: object properties: @@ -3364,3 +3857,4 @@ definitions: type: integer format: uint8 description: Retry Count to detect failure + \ No newline at end of file diff --git a/common/common.go b/common/common.go index 7b23faf3d..06418601e 100644 --- a/common/common.go +++ b/common/common.go @@ -634,6 +634,140 @@ type GoBGPNeighGetMod struct { Uptime string `json:"uptime"` } +type GoBGPPolicyDefinedSetMod struct { + Name string `json:"name"` + DefinedTypeString string `json:"definedTypeString"` + List []string `json:"list,omitempty"` + PrefixList []Prefix `json:"prefixList,omitempty"` +} + +// GoBGPPolicyNeighMod - Info related to goBGP policy about neigh +type GoBGPPolicyNeighMod struct { + Name string `json:"name"` + NeighborInfoList []string `json:"neighborInfoList"` +} + +// GoBGPPolicyCommunityMod - Info related to goBGP policy about neigh +type GoBGPPolicyCommunityMod struct { + Name string `json:"name"` + CommunityList []string `json:"communityList"` +} + +// GoBGPPolicyExtCommunityListMod - Info related to goBGP policy about neigh +type GoBGPPolicyExtCommunityMod struct { + Name string `json:"name"` + ExtCommunityList []string `json:"extCommunityList"` +} + +// GoBGPPolicyAsPAthMod - Info related to goBGP policy about neigh +type GoBGPPolicyAsPathMod struct { + Name string `json:"name"` + AsPathList []string `json:"asPathList"` +} + +// GoBGPPolicyLargeCommunityMod - Info related to goBGP policy about neigh +type GoBGPPolicyLargeCommunityMod struct { + Name string `json:"name"` + LargeCommunityList []string `json:"largeCommunityList"` +} + +// GoBGPPolicyPrefixSetMod - Info related to goBGP Policy prefix +type GoBGPPolicyPrefixSetMod struct { + Name string `json:"name"` + PrefixList []Prefix `json:"prefixList"` +} + +// Prefix - Info related to goBGP Policy Prefix +type Prefix struct { + IpPrefix string `json:"ipPrefix"` + MasklengthRange string `json:"masklengthRange"` +} + +// GoBGPPolicyDefineSetMod - +type GoBGPPolicyDefinitionsMod struct { + Name string `json:"name"` + Statement []Statement `json:"prefixList"` +} + +type Statement struct { + Name string `json:"name,omitempty"` + Conditions Conditions `json:"conditions,omitempty"` + Actions Actions `json:"actions,omitempty"` +} + +type Actions struct { + RouteDisposition string `json:"routeDisposition"` + BGPActions BGPActions `json:"bgpActions,omitempty"` +} + +type BGPActions struct { + SetMed string `json:"setMed,omitempty"` + SetCommunity SetCommunity `json:"setCommunity,omitempty"` + SetExtCommunity SetCommunity `json:"setExtCommunity,omitempty"` + SetLargeCommunity SetCommunity `json:"setLargeCommunity,omitempty"` + SetNextHop string `json:"setNextHop,omitempty"` + SetLocalPerf int `json:"setLocalPerf,omitempty"` + SetAsPathPrepend SetAsPathPrepend `json:"setAsPathPrepend,omitempty"` +} + +type SetCommunity struct { + Options string `json:"options,omitempty"` + SetCommunityMethod []string `json:"setCommunityMethod,omitempty"` +} + +type SetAsPathPrepend struct { + ASN string `json:"as,omitempty"` + RepeatN int `json:"repeatN,omitempty"` +} + +type Conditions struct { + PrefixSet MatchPrefixSet `json:"matchPrefixSet,omitempty"` + NeighborSet MatchNeighborSet `json:"matchNeighborSet,omitempty"` + BGPConditions BGPConditions `json:"bgpconditions"` +} + +type MatchNeighborSet struct { + MatchSetOption string `json:"matchSetOption,omitempty"` + NeighborSet string `json:"NeighborSet,omitempty"` +} + +type MatchPrefixSet struct { + MatchSetOption string `json:"matchSetOption,omitempty"` + PrefixSet string `json:"prefixSet,omitempty"` +} + +type BGPConditions struct { + AfiSafiIn []string `json:"afiSafiIn,omitempty"` + AsPathSet BGPAsPathSet `json:"matchAsPathSet,omitempty"` + AsPathLength BGPAsPathLength `json:"asPathLength,omitempty"` + CommunitySet BGPCommunitySet `json:"matchCommunitySet,omitempty"` + ExtCommunitySet BGPCommunitySet `json:"matchExtCommunitySet,omitempty"` + LargeCommunitySet BGPCommunitySet `json:"largeCommunitySet,omitempty"` + RouteType string `json:"routeType,omitempty"` + NextHopInList []string `json:"nextHopInList,omitempty"` + Rpki string `json:"rpki,omitempty"` +} + +type BGPAsPathLength struct { + Operator string `json:"Operator,omitempty"` + Value int `json:"Value,omitempty"` +} +type BGPAsPathSet struct { + AsPathSet string `json:"asPathSet,omitempty"` + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} +type BGPCommunitySet struct { + CommunitySet string `json:"communitySet,omitempty"` + MatchSetOptions string `json:"matchSetOptions,omitempty"` +} + +type GoBGPPolicyApply struct { + NeighIPAddress string `json:"ipAddress,omitempty"` + PolicyType string `json:"policyType,omitempty"` + Polices []string `json:"polices,omitempty"` + RouteAction string `json:"routeAction,omitempty"` +} + // Equal - check if two session tunnel entries are equal func (ut *SessTun) Equal(ut1 *SessTun) bool { if ut.TeID == ut1.TeID && ut.Addr.Equal(ut1.Addr) { @@ -864,6 +998,17 @@ type NetHookInterface interface { NetGoBGPNeighGet() ([]GoBGPNeighGetMod, error) NetGoBGPNeighAdd(nm *GoBGPNeighMod) (int, error) NetGoBGPNeighDel(nm *GoBGPNeighMod) (int, error) + + NetGoBGPPolicyDefinedSetGet(string, string) ([]GoBGPPolicyDefinedSetMod, error) + NetGoBGPPolicyDefinedSetAdd(nm *GoBGPPolicyDefinedSetMod) (int, error) + NetGoBGPPolicyDefinedSetDel(nm *GoBGPPolicyDefinedSetMod) (int, error) + + NetGoBGPPolicyDefinitionsGet() ([]GoBGPPolicyDefinitionsMod, error) + NetGoBGPPolicyDefinitionAdd(nm *GoBGPPolicyDefinitionsMod) (int, error) + NetGoBGPPolicyDefinitionDel(nm *GoBGPPolicyDefinitionsMod) (int, error) + + NetGoBGPPolicyApplyAdd(nm *GoBGPPolicyApply) (int, error) + NetGoBGPGCAdd(gc *GoBGPGlobalConfig) (int, error) NetBFDGet() ([]BFDMod, error) NetBFDAdd(bm *BFDMod) (int, error) diff --git a/pkg/loxinet/apiclient.go b/pkg/loxinet/apiclient.go index 28faf9349..4f79c57e1 100644 --- a/pkg/loxinet/apiclient.go +++ b/pkg/loxinet/apiclient.go @@ -686,3 +686,80 @@ func (na *NetAPIStruct) NetGoBGPGCAdd(param *cmn.GoBGPGlobalConfig) (int, error) func (na *NetAPIStruct) NetHandlePanic() { mh.dp.DpHooks.DpEbpfUnInit() } + +func (na *NetAPIStruct) NetGoBGPPolicyDefinedSetGet(name string, DefinedTypeString string) ([]cmn.GoBGPPolicyDefinedSetMod, error) { + if mh.bgp != nil { + a, err := mh.bgp.GetPolicyDefinedSet(name, DefinedTypeString) + if err != nil { + return nil, err + } + return a, nil + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return nil, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyPrefixAdd - Add Prefixset in bgp +func (na *NetAPIStruct) NetGoBGPPolicyDefinedSetAdd(param *cmn.GoBGPPolicyDefinedSetMod) (int, error) { + if mh.bgp != nil { + return mh.bgp.AddPolicyDefinedSets(*param) + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return 0, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyPrefixAdd - Add Prefixset in bgp +func (na *NetAPIStruct) NetGoBGPPolicyDefinedSetDel(param *cmn.GoBGPPolicyDefinedSetMod) (int, error) { + if mh.bgp != nil { + return mh.bgp.DelPolicyDefinedSets(param.Name, param.DefinedTypeString) + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return 0, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyDefinitionsGet - Add bgp neigh to gobgp +func (na *NetAPIStruct) NetGoBGPPolicyDefinitionsGet() ([]cmn.GoBGPPolicyDefinitionsMod, error) { + if mh.bgp != nil { + a, err := mh.bgp.GetPolicyDefinitions() + if err != nil { + return nil, err + } + return a, nil + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return nil, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyNeighAdd - Add bgp neigh to gobgp +func (na *NetAPIStruct) NetGoBGPPolicyDefinitionAdd(param *cmn.GoBGPPolicyDefinitionsMod) (int, error) { + if mh.bgp != nil { + return mh.bgp.AddPolicyDefinitions(param.Name, param.Statement) + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return 0, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyNeighAdd - Add bgp neigh to gobgp +func (na *NetAPIStruct) NetGoBGPPolicyDefinitionDel(param *cmn.GoBGPPolicyDefinitionsMod) (int, error) { + if mh.bgp != nil { + return mh.bgp.DelPolicyDefinitions(param.Name) + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return 0, errors.New("loxilb BGP mode is disabled") + +} + +// NetGoBGPPolicyNeighAdd - Add bgp neigh to gobgp +func (na *NetAPIStruct) NetGoBGPPolicyApplyAdd(param *cmn.GoBGPPolicyApply) (int, error) { + if mh.bgp != nil { + return mh.bgp.BGPApplyPolicyToNeighbor("add", param.NeighIPAddress, param.PolicyType, param.Polices, param.RouteAction) + } + tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") + return 0, errors.New("loxilb BGP mode is disabled") + +} diff --git a/pkg/loxinet/gobgpclient.go b/pkg/loxinet/gobgpclient.go index 18ca1eef9..798456bd5 100644 --- a/pkg/loxinet/gobgpclient.go +++ b/pkg/loxinet/gobgpclient.go @@ -24,6 +24,7 @@ import ( "net" "os" "os/exec" + "strconv" "strings" "sync" "time" @@ -1070,6 +1071,655 @@ func (gbh *GoBgpH) createSetLocalPrefPolicy(name string, val uint32) (int, error return 0, err } +// MakePrefixDefinedSet - Make Prefix DefinedSet +func (gbh *GoBgpH) MakePrefixDefinedSet(prefixList []cmn.Prefix) ([]*api.Prefix, error) { + var ret []*api.Prefix + for _, prefix := range prefixList { + // Make Prefix + Prefix := api.Prefix{} + Prefix.IpPrefix = prefix.IpPrefix + // Parse prefix.MasklengthRange + Masks := strings.Split(prefix.MasklengthRange, "..") + if len(Masks) == 2 { + MaskLengthMin, _ := strconv.Atoi(Masks[0]) + Prefix.MaskLengthMin = uint32(MaskLengthMin) + MaskLengthMax, _ := strconv.Atoi(Masks[1]) + Prefix.MaskLengthMax = uint32(MaskLengthMax) + } else { + return nil, errors.New("Mask format is wrong") + } + ret = append(ret, &Prefix) + } + + return ret, nil +} + +// GetPolicyDefinedSet - Get Policy Defined Set +func (gbh *GoBgpH) GetPolicyDefinedSet(name string, DefinedTypeString string) ([]cmn.GoBGPPolicyDefinedSetMod, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var DefinedType api.DefinedType + var ret []cmn.GoBGPPolicyDefinedSetMod + var req api.ListDefinedSetRequest + switch DefinedTypeString { + case "prefix", "Prefix": + DefinedType = api.DefinedType_PREFIX + case "neigh", "neighbor", "nei", "Neighbor", "Neigh", "Nei": + DefinedType = api.DefinedType_NEIGHBOR + case "Community", "community": + DefinedType = api.DefinedType_COMMUNITY + case "ExtCommunity", "extCommunity", "extcommunity": + DefinedType = api.DefinedType_EXT_COMMUNITY + case "LargeCommunity", "largecommunity", "largeCommunity", "Largecommunity": + DefinedType = api.DefinedType_LARGE_COMMUNITY + case "AsPath", "asPath", "ASPath", "aspath": + DefinedType = api.DefinedType_AS_PATH + default: + return ret, fmt.Errorf("Unsupported type") + } + + if name == "all" { + req.DefinedType = DefinedType + } else { + req.DefinedType = DefinedType + req.Name = name + } + stream, err := gbh.client.ListDefinedSet(ctx, &req) + if err != nil { + return ret, err + } + + for { + r, err := stream.Recv() + if err == io.EOF { + break + } else if err != nil { + fmt.Println(err) + return ret, err + } + var tmp cmn.GoBGPPolicyDefinedSetMod + switch DefinedTypeString { + case "prefix", "Prefix": + tmp.Name = r.DefinedSet.Name + for _, prefix := range r.DefinedSet.Prefixes { + if prefix != nil { + tmpprefix := cmn.Prefix{ + IpPrefix: prefix.IpPrefix, + MasklengthRange: fmt.Sprintf("%d..%d", prefix.MaskLengthMin, prefix.MaskLengthMax), + } + tmp.PrefixList = append(tmp.PrefixList, tmpprefix) + } + } + default: + tmp.Name = r.DefinedSet.Name + tmp.List = r.DefinedSet.List + } + ret = append(ret, tmp) + } + return ret, nil +} + +// GetPolicyDefinitions - Get Policy Definitions +func (gbh *GoBgpH) GetPolicyDefinitions() ([]cmn.GoBGPPolicyDefinitionsMod, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var ret []cmn.GoBGPPolicyDefinitionsMod + stream, err := gbh.client.ListPolicy(ctx, &api.ListPolicyRequest{}) + if err != nil { + return nil, err + } + for { + r, err := stream.Recv() + if err == io.EOF { + break + } else if err != nil { + return nil, err + } + tmpPolicy := cmn.GoBGPPolicyDefinitionsMod{ + Name: r.Policy.Name, + } + + for _, statement := range r.Policy.GetStatements() { + tmpStatement := cmn.Statement{ + Name: statement.Name, + } + // Condition Match + var PrefixSet cmn.MatchPrefixSet + var NeighborSet cmn.MatchNeighborSet + var BGPConditions cmn.BGPConditions + + fmt.Println(statement) + if t := statement.Conditions.GetPrefixSet(); t != nil { + PrefixSet.PrefixSet = t.Name + PrefixSet.MatchSetOption = gbh.GetTypeMatchSet(t.Type) + tmpStatement.Conditions.PrefixSet = PrefixSet + } + + if t := statement.Conditions.GetNeighborSet(); t != nil { + NeighborSet.NeighborSet = t.Name + NeighborSet.MatchSetOption = gbh.GetTypeMatchSet(t.Type) + tmpStatement.Conditions.NeighborSet = NeighborSet + } + if t := statement.Conditions.GetAfiSafiIn(); t != nil { + for _, afi := range t { + BGPConditions.AfiSafiIn = append(BGPConditions.AfiSafiIn, bgp.AfiSafiToRouteFamily(uint16(afi.Afi), uint8(afi.Safi)).String()) + } + tmpStatement.Conditions.BGPConditions.AfiSafiIn = BGPConditions.AfiSafiIn + } + if t := statement.Conditions.GetAsPathLength(); t != nil { + tmpStatement.Conditions.BGPConditions.AsPathLength.Value = int(t.Length) + switch t.Type { + case api.AsPathLength_EQ: + tmpStatement.Conditions.BGPConditions.AsPathLength.Operator = "eq" + case api.AsPathLength_GE: + tmpStatement.Conditions.BGPConditions.AsPathLength.Operator = "ge" + case api.AsPathLength_LE: + tmpStatement.Conditions.BGPConditions.AsPathLength.Operator = "le" + } + } + if t := statement.Conditions.GetAsPathSet(); t != nil { + tmpStatement.Conditions.BGPConditions.AsPathSet.AsPathSet = t.Name + tmpStatement.Conditions.BGPConditions.AsPathSet.MatchSetOptions = gbh.GetTypeMatchSet(t.Type) + } + if t := statement.Conditions.GetCommunitySet(); t != nil { + tmpStatement.Conditions.BGPConditions.CommunitySet.CommunitySet = t.Name + tmpStatement.Conditions.BGPConditions.CommunitySet.MatchSetOptions = gbh.GetTypeMatchSet(t.Type) + } + if t := statement.Conditions.GetExtCommunitySet(); t != nil { + tmpStatement.Conditions.BGPConditions.ExtCommunitySet.CommunitySet = t.Name + tmpStatement.Conditions.BGPConditions.ExtCommunitySet.MatchSetOptions = gbh.GetTypeMatchSet(t.Type) + } + if t := statement.Conditions.GetLargeCommunitySet(); t != nil { + tmpStatement.Conditions.BGPConditions.LargeCommunitySet.CommunitySet = t.Name + tmpStatement.Conditions.BGPConditions.LargeCommunitySet.MatchSetOptions = gbh.GetTypeMatchSet(t.Type) + } + + if t := statement.Conditions.GetNextHopInList(); t != nil { + tmpStatement.Conditions.BGPConditions.NextHopInList = t + } + + if t := statement.Conditions.GetRouteType(); t != api.Conditions_ROUTE_TYPE_NONE { + switch t { + case api.Conditions_ROUTE_TYPE_INTERNAL: + tmpStatement.Conditions.BGPConditions.RouteType = "internal" + case api.Conditions_ROUTE_TYPE_EXTERNAL: + tmpStatement.Conditions.BGPConditions.RouteType = "external" + case api.Conditions_ROUTE_TYPE_LOCAL: + tmpStatement.Conditions.BGPConditions.RouteType = "local" + } + } + + if t := statement.Conditions.GetRpkiResult(); t != 0 { + switch t { + case 1: // RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND + tmpStatement.Conditions.BGPConditions.Rpki = "not-found" + case 2: //RPKI_VALIDATION_RESULT_TYPE_VALID + tmpStatement.Conditions.BGPConditions.Rpki = "valid" + case 3: //RPKI_VALIDATION_RESULT_TYPE_INVALID + tmpStatement.Conditions.BGPConditions.Rpki = "invalid" + } + } + // Action Match + if t := statement.Actions.GetAsPrepend(); t != nil { + tmpStatement.Actions.BGPActions.SetAsPathPrepend.ASN = fmt.Sprintf("%d", t.Asn) + tmpStatement.Actions.BGPActions.SetAsPathPrepend.RepeatN = int(t.Repeat) + } + if t := statement.Actions.GetCommunity(); t != nil { + tmpStatement.Actions.BGPActions.SetCommunity.Options = gbh.GetTypeCommunityAction(t.Type) + tmpStatement.Actions.BGPActions.SetCommunity.SetCommunityMethod = t.Communities + } + if t := statement.Actions.GetExtCommunity(); t != nil { + tmpStatement.Actions.BGPActions.SetExtCommunity.Options = gbh.GetTypeCommunityAction(t.Type) + tmpStatement.Actions.BGPActions.SetExtCommunity.SetCommunityMethod = t.Communities + } + if t := statement.Actions.GetLargeCommunity(); t != nil { + tmpStatement.Actions.BGPActions.SetLargeCommunity.Options = gbh.GetTypeCommunityAction(t.Type) + tmpStatement.Actions.BGPActions.SetLargeCommunity.SetCommunityMethod = t.Communities + } + if t := statement.Actions.GetLocalPref(); t != nil { + tmpStatement.Actions.BGPActions.SetLocalPerf = int(t.Value) + } + if t := statement.Actions.GetMed(); t != nil { + tmpStatement.Actions.BGPActions.SetMed = fmt.Sprintf("%d", t.Value) + } + if t := statement.Actions.GetNexthop(); t != nil { + tmpStatement.Actions.BGPActions.SetNextHop = t.Address + } + + if t := statement.Actions.GetRouteAction(); t != api.RouteAction_NONE { + tmpStatement.Actions.RouteDisposition = gbh.GetActionRoute(t) + } + + tmpPolicy.Statement = append(tmpPolicy.Statement, tmpStatement) + } + + ret = append(ret, tmpPolicy) + } + fmt.Println(ret) + return ret, nil +} + +// AddPolicyDefinedSets - Add Policy Defined Set like a Prefix, neighbor. etc +func (gbh *GoBgpH) AddPolicyDefinedSets(df cmn.GoBGPPolicyDefinedSetMod) (int, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var DefinedType api.DefinedType + var DefinedSet api.DefinedSet + switch df.DefinedTypeString { + case "prefix", "Prefix": + DefinedType = api.DefinedType_PREFIX + case "neigh", "neighbor", "nei", "Neighbor", "Neigh", "Nei": + DefinedType = api.DefinedType_NEIGHBOR + case "Community", "community": + DefinedType = api.DefinedType_COMMUNITY + case "ExtCommunity", "extCommunity", "extcommunity": + DefinedType = api.DefinedType_EXT_COMMUNITY + case "LargeCommunity", "largecommunity", "largeCommunity", "Largecommunity": + DefinedType = api.DefinedType_LARGE_COMMUNITY + case "AsPath", "asPath", "ASPath": + DefinedType = api.DefinedType_AS_PATH + } + Prefixes, err := gbh.MakePrefixDefinedSet(df.PrefixList) + if err != nil { + return 0, err + } + DefinedSet = api.DefinedSet{ + DefinedType: DefinedType, + Name: df.Name, + List: df.List, + Prefixes: Prefixes, + } + + _, err = gbh.client.AddDefinedSet(ctx, &api.AddDefinedSetRequest{DefinedSet: &DefinedSet}) + return 0, err +} + +// DelDefinedSets - Delete DefinedSet +func (gbh *GoBgpH) DelPolicyDefinedSets(Name string, DefinedTypeString string) (int, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var DefinedType api.DefinedType + + switch DefinedTypeString { + case "prefix", "Prefix": + DefinedType = api.DefinedType_PREFIX + case "neigh", "neighbor", "nei", "Neighbor", "Neigh", "Nei": + DefinedType = api.DefinedType_NEIGHBOR + case "Community", "community": + DefinedType = api.DefinedType_COMMUNITY + case "ExtCommunity", "extCommunity", "extcommunity": + DefinedType = api.DefinedType_EXT_COMMUNITY + case "LargeCommunity", "largecommunity", "largeCommunity", "Largecommunity": + DefinedType = api.DefinedType_LARGE_COMMUNITY + case "AsPath", "asPath", "ASPath": + DefinedType = api.DefinedType_AS_PATH + } + // Make DefinedSet + DefineSet := api.DefinedSet{ + DefinedType: DefinedType, + Name: Name, + } + + _, err := gbh.client.DeleteDefinedSet(ctx, &api.DeleteDefinedSetRequest{ + DefinedSet: &DefineSet, + All: true, + }) + return 0, err +} + +// AddPolicyDefinitions - Add Policy with definitions +func (gbh *GoBgpH) AddPolicyDefinitions(name string, stmt []cmn.Statement) (int, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + stmts := make([]*api.Statement, 0) + + // Common statement to goBGP statement + for _, statement := range stmt { + tmpStatement := &api.Statement{ + Name: statement.Name, + Conditions: &api.Conditions{}, + Actions: &api.Actions{}, + } + // Prefix and Neigh Condition add (any(), invert) + if statement.Conditions.PrefixSet.PrefixSet != "" { + var PrefixSet api.MatchSet + PrefixSet.Name = statement.Conditions.PrefixSet.PrefixSet + PrefixSet.Type = gbh.GetMatchSetType(statement.Conditions.PrefixSet.MatchSetOption) + tmpStatement.Conditions.PrefixSet = &PrefixSet + } + if statement.Conditions.NeighborSet.NeighborSet != "" { + var NeighborSet api.MatchSet + NeighborSet.Name = statement.Conditions.NeighborSet.NeighborSet + NeighborSet.Type = gbh.GetMatchSetType(statement.Conditions.NeighborSet.MatchSetOption) + tmpStatement.Conditions.NeighborSet = &NeighborSet + } + // BGP condition + if statement.Conditions.BGPConditions.AsPathSet.AsPathSet != "" { + var AsPathSet api.MatchSet + AsPathSet.Name = statement.Conditions.BGPConditions.AsPathSet.AsPathSet + AsPathSet.Type = gbh.GetMatchSetType(statement.Conditions.BGPConditions.AsPathSet.MatchSetOptions) + tmpStatement.Conditions.AsPathSet = &AsPathSet + } + if statement.Conditions.BGPConditions.CommunitySet.CommunitySet != "" { + var CommunitySet api.MatchSet + CommunitySet.Name = statement.Conditions.BGPConditions.CommunitySet.CommunitySet + CommunitySet.Type = gbh.GetMatchSetType(statement.Conditions.BGPConditions.CommunitySet.MatchSetOptions) + tmpStatement.Conditions.CommunitySet = &CommunitySet + } + if statement.Conditions.BGPConditions.ExtCommunitySet.CommunitySet != "" { + var ExtCommunitySet api.MatchSet + ExtCommunitySet.Name = statement.Conditions.BGPConditions.ExtCommunitySet.CommunitySet + ExtCommunitySet.Type = gbh.GetMatchSetType(statement.Conditions.BGPConditions.ExtCommunitySet.MatchSetOptions) + tmpStatement.Conditions.ExtCommunitySet = &ExtCommunitySet + } + if statement.Conditions.BGPConditions.LargeCommunitySet.CommunitySet != "" { + var LargeCommunitySet api.MatchSet + LargeCommunitySet.Name = statement.Conditions.BGPConditions.LargeCommunitySet.CommunitySet + LargeCommunitySet.Type = gbh.GetMatchSetType(statement.Conditions.BGPConditions.LargeCommunitySet.MatchSetOptions) + tmpStatement.Conditions.LargeCommunitySet = &LargeCommunitySet + } + if len(statement.Conditions.BGPConditions.AfiSafiIn) != 0 { + afiSafisInList := make([]*api.Family, 0, len(statement.Conditions.BGPConditions.AfiSafiIn)) + for _, afisafi := range statement.Conditions.BGPConditions.AfiSafiIn { + afi, safi := bgp.RouteFamilyToAfiSafi(bgp.AddressFamilyValueMap[afisafi]) + afiSafisInList = append(afiSafisInList, apiutil.ToApiFamily(afi, safi)) + } + tmpStatement.Conditions.AfiSafiIn = afiSafisInList + } + if statement.Conditions.BGPConditions.AsPathLength.Operator != "" { + var AsPathLength api.AsPathLength + switch strings.ToLower(statement.Conditions.BGPConditions.AsPathLength.Operator) { + case "eq": + AsPathLength.Type = api.AsPathLength_EQ + case "ge": + AsPathLength.Type = api.AsPathLength_GE + case "le": + AsPathLength.Type = api.AsPathLength_LE + } + AsPathLength.Length = uint32(statement.Conditions.BGPConditions.AsPathLength.Value) + tmpStatement.Conditions.AsPathLength = &AsPathLength + } + // From gobgp code + type RpkiValidationResultType string + const ( + RPKI_VALIDATION_RESULT_TYPE_NONE RpkiValidationResultType = "none" + RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND RpkiValidationResultType = "not-found" + RPKI_VALIDATION_RESULT_TYPE_VALID RpkiValidationResultType = "valid" + RPKI_VALIDATION_RESULT_TYPE_INVALID RpkiValidationResultType = "invalid" + ) + + var RpkiValidationResultTypeToIntMap = map[RpkiValidationResultType]int{ + RPKI_VALIDATION_RESULT_TYPE_NONE: 0, + RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND: 1, + RPKI_VALIDATION_RESULT_TYPE_VALID: 2, + RPKI_VALIDATION_RESULT_TYPE_INVALID: 3, + } + if statement.Conditions.BGPConditions.Rpki != "" { + switch strings.ToLower(statement.Conditions.BGPConditions.Rpki) { + case "valid": + tmpStatement.Conditions.RpkiResult = int32(RpkiValidationResultTypeToIntMap[RPKI_VALIDATION_RESULT_TYPE_VALID]) + case "invalid": + tmpStatement.Conditions.RpkiResult = int32(RpkiValidationResultTypeToIntMap[RPKI_VALIDATION_RESULT_TYPE_INVALID]) + case "not-found": + tmpStatement.Conditions.RpkiResult = int32(RpkiValidationResultTypeToIntMap[RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND]) + } + } + if statement.Conditions.BGPConditions.RouteType != "" { + switch strings.ToLower(statement.Conditions.BGPConditions.RouteType) { + case "internal": + tmpStatement.Conditions.RouteType = api.Conditions_ROUTE_TYPE_INTERNAL + case "external": + tmpStatement.Conditions.RouteType = api.Conditions_ROUTE_TYPE_EXTERNAL + case "local": + tmpStatement.Conditions.RouteType = api.Conditions_ROUTE_TYPE_LOCAL + } + } + + if len(statement.Conditions.BGPConditions.NextHopInList) != 0 { + tmpStatement.Conditions.NextHopInList = statement.Conditions.BGPConditions.NextHopInList + } + + // Action + tmpStatement.Actions.RouteAction = gbh.GetRouteAction(statement.Actions.RouteDisposition) + + if statement.Actions.BGPActions.SetAsPathPrepend.ASN != "" { + var AsPrepend api.AsPrependAction + tmpASN, _ := strconv.Atoi(statement.Actions.BGPActions.SetAsPathPrepend.ASN) + AsPrepend.Asn = uint32(tmpASN) + AsPrepend.Repeat = uint32(statement.Actions.BGPActions.SetAsPathPrepend.RepeatN) + tmpStatement.Actions.AsPrepend = &AsPrepend + } + + if len(statement.Actions.BGPActions.SetCommunity.SetCommunityMethod) != 0 { + var Community api.CommunityAction + Community.Communities = statement.Actions.BGPActions.SetCommunity.SetCommunityMethod + Community.Type = gbh.GetCommunityActionType(statement.Actions.BGPActions.SetCommunity.Options) + tmpStatement.Actions.Community = &Community + } + if len(statement.Actions.BGPActions.SetExtCommunity.SetCommunityMethod) != 0 { + var Community api.CommunityAction + Community.Communities = statement.Actions.BGPActions.SetExtCommunity.SetCommunityMethod + Community.Type = gbh.GetCommunityActionType(statement.Actions.BGPActions.SetExtCommunity.Options) + tmpStatement.Actions.ExtCommunity = &Community + } + if len(statement.Actions.BGPActions.SetLargeCommunity.SetCommunityMethod) != 0 { + var Community api.CommunityAction + Community.Communities = statement.Actions.BGPActions.SetLargeCommunity.SetCommunityMethod + Community.Type = gbh.GetCommunityActionType(statement.Actions.BGPActions.SetLargeCommunity.Options) + tmpStatement.Actions.LargeCommunity = &Community + } + + if statement.Actions.BGPActions.SetMed != "" { + var Med api.MedAction + med, err := strconv.ParseInt(statement.Actions.BGPActions.SetMed, 10, 32) + if err != nil { + return 0, err + } + Med.Value = med + Med.Type = api.MedAction_REPLACE // Cause set-med + tmpStatement.Actions.Med = &Med + } + if statement.Actions.BGPActions.SetLocalPerf != 0 { + var LocalPref api.LocalPrefAction + LocalPref.Value = uint32(statement.Actions.BGPActions.SetLocalPerf) + tmpStatement.Actions.LocalPref = &LocalPref + } + if statement.Actions.BGPActions.SetNextHop != "" { + var Nexthop api.NexthopAction + Nexthop.Address = statement.Actions.BGPActions.SetNextHop + tmpStatement.Actions.Nexthop = &Nexthop + } + + stmts = append(stmts, tmpStatement) + } + p := &api.Policy{ + Name: name, + Statements: stmts, + } + + _, err := gbh.client.AddPolicy(ctx, + &api.AddPolicyRequest{ + Policy: p, + }) + return 0, err +} + +// DelPolicyDefinitions - Del Policy Definitions +func (gbh *GoBgpH) DelPolicyDefinitions(name string) (int, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + p := &api.Policy{ + Name: name, + } + + _, err := gbh.client.DeletePolicy(ctx, + &api.DeletePolicyRequest{ + Policy: p, + All: true, + }) + return 0, err +} + +// GetCommunityActionType - String to CommunityAction_Type +func (gbh *GoBgpH) GetCommunityActionType(name string) api.CommunityAction_Type { + var ret api.CommunityAction_Type // add remove replace + if name == "add" { + ret = api.CommunityAction_ADD + } else if name == "remove" { + ret = api.CommunityAction_REMOVE + } else { + ret = api.CommunityAction_REPLACE + } + return ret +} + +// GetCommunityActionType - String to CommunityAction_Type +func (gbh *GoBgpH) GetTypeCommunityAction(CommunityActionType api.CommunityAction_Type) string { + var ret string // add remove replace + if CommunityActionType == api.CommunityAction_ADD { + ret = "add" + } else if CommunityActionType == api.CommunityAction_REMOVE { + ret = "remove" + } else { + ret = "replace" + } + return ret +} + +// GetMatchSetType - String to MatchSet_Type +func (gbh *GoBgpH) GetMatchSetType(name string) api.MatchSet_Type { + var ret api.MatchSet_Type + if name == "any" { + ret = api.MatchSet_ANY + } else if name == "all" { + ret = api.MatchSet_ALL + } else if name == "invert" { + ret = api.MatchSet_INVERT + } else { + ret = api.MatchSet_ANY + } + return ret +} + +// GetTypeMatchSet - MatchSet_Type to String +func (gbh *GoBgpH) GetTypeMatchSet(matchSet api.MatchSet_Type) string { + var ret string + if matchSet == api.MatchSet_ANY { + ret = "any" + } else if matchSet == api.MatchSet_ALL { + ret = "all" + } else if matchSet == api.MatchSet_INVERT { + ret = "invert" + } else { + ret = "any" + } + return ret +} + +// GetRouteAction - String to RouteAction +func (gbh *GoBgpH) GetRouteAction(name string) api.RouteAction { + var ret api.RouteAction + if name == "accept-route" { + ret = api.RouteAction_ACCEPT + } else if name == "reject-route" { + ret = api.RouteAction_REJECT + } else { + ret = api.RouteAction_NONE + } + return ret +} + +// GetActionRoute - RouteAction to String +func (gbh *GoBgpH) GetActionRoute(route api.RouteAction) string { + var ret string + if route == api.RouteAction_ACCEPT { + ret = "accept-route" + } else if route == api.RouteAction_REJECT { + ret = "reject-route" + } else { + ret = "none" + } + return ret +} + +// BGPApplyPolicyToNeighbor - Routine to add BGP Policy to goBGP server +func (gbh *GoBgpH) BGPApplyPolicyToNeighbor(cmdType, neigh string, polType string, policies []string, routeAction string) (int, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + var err error + assign := &api.PolicyAssignment{ + Name: neigh, + } + + switch strings.ToLower(polType) { + case "import": + assign.Direction = api.PolicyDirection_IMPORT + case "export": + assign.Direction = api.PolicyDirection_EXPORT + } + switch cmdType { + case "add", "set": + switch routeAction { + case "accept": + assign.DefaultAction = api.RouteAction_ACCEPT + case "reject": + assign.DefaultAction = api.RouteAction_REJECT + } + } + ps := make([]*api.Policy, 0, len(policies)) + for _, name := range policies { + ps = append(ps, &api.Policy{Name: name}) + } + assign.Policies = ps + switch cmdType { + case "add": + _, err = gbh.client.AddPolicyAssignment(ctx, &api.AddPolicyAssignmentRequest{ + Assignment: assign, + }) + case "set": + _, err = gbh.client.SetPolicyAssignment(ctx, &api.SetPolicyAssignmentRequest{ + Assignment: assign, + }) + case "del": + all := false + if len(policies) == 0 { + all = true + } + _, err = gbh.client.DeletePolicyAssignment(ctx, &api.DeletePolicyAssignmentRequest{ + Assignment: assign, + All: all, + }) + } + if err != nil { + return 0, err + } + return 0, nil +} + +// GetPolicy - Routine to apply global policy statement +func (gbh *GoBgpH) GetPolicy(name string) (*api.Policy, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + policies := make([]*api.Policy, 0) + stream, err := gbh.client.ListPolicy(ctx, &api.ListPolicyRequest{ + Name: name, + }) + if err != nil { + return nil, err + } + for { + r, err := stream.Recv() + if err == io.EOF { + break + } else if err != nil { + return nil, err + } + policies = append(policies, r.Policy) + } + + return policies[0], nil +} + // addPolicy - Routine to apply global policy statement func (gbh *GoBgpH) addPolicy(name string, stmt string) (int, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)