From fe197bb1f4fa82aff289c82c7982b26f8e5e8ef6 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Tue, 13 Feb 2024 15:57:36 +0100 Subject: [PATCH] tocidr for ingress rules --- api/models/v1_firewall_ingress_rule.go | 17 +++++++++++++++++ metal-api.json | 10 +++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/api/models/v1_firewall_ingress_rule.go b/api/models/v1_firewall_ingress_rule.go index d0af979..0535959 100644 --- a/api/models/v1_firewall_ingress_rule.go +++ b/api/models/v1_firewall_ingress_rule.go @@ -34,6 +34,10 @@ type V1FirewallIngressRule struct { // the protocol for the rule, defaults to tcp // Enum: [tcp udp] Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"` + + // the cidrs affected by this rule + // Required: true + ToCidrs []string `json:"to_cidrs" yaml:"to_cidrs"` } // Validate validates this v1 firewall ingress rule @@ -52,6 +56,10 @@ func (m *V1FirewallIngressRule) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateToCidrs(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -118,6 +126,15 @@ func (m *V1FirewallIngressRule) validateProtocol(formats strfmt.Registry) error return nil } +func (m *V1FirewallIngressRule) validateToCidrs(formats strfmt.Registry) error { + + if err := validate.Required("to_cidrs", "body", m.ToCidrs); err != nil { + return err + } + + return nil +} + // ContextValidate validates this v1 firewall ingress rule based on context it is used func (m *V1FirewallIngressRule) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil diff --git a/metal-api.json b/metal-api.json index cc5526a..4715303 100644 --- a/metal-api.json +++ b/metal-api.json @@ -1358,11 +1358,19 @@ "udp" ], "type": "string" + }, + "to_cidrs": { + "description": "the cidrs affected by this rule", + "items": { + "type": "string" + }, + "type": "array" } }, "required": [ "from_cidrs", - "ports" + "ports", + "to_cidrs" ] }, "v1.FirewallResponse": {