[pve-devel] applied: [PATCH pve-firewall] api: rules: add return type to list_rules endpoint
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Oct 22 16:38:19 CEST 2025
applied, thanks
On Wed, Oct 22, 2025 at 01:17:37PM +0200, Hannes Laimer wrote:
> We already have this for the GET endpoint for a rule, so we just reuse
> that for the items in the list.
>
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
> This is a little odd since we return the exact same data in the list as
> we do in the endpoint for a single rule. So unless you already know the
> pos of a rule, you could just list them and wouldn't need to call
> rules/{pos} at all...
>
> We also need this to correctly generate the rust types for the `rules`
> endpoint.
>
> src/PVE/API2/Firewall/Rules.pm | 130 ++++++++++++++++-----------------
> 1 file changed, 64 insertions(+), 66 deletions(-)
>
> diff --git a/src/PVE/API2/Firewall/Rules.pm b/src/PVE/API2/Firewall/Rules.pm
> index 992ad9a..baed539 100644
> --- a/src/PVE/API2/Firewall/Rules.pm
> +++ b/src/PVE/API2/Firewall/Rules.pm
> @@ -19,6 +19,68 @@ my $api_properties = {
> },
> };
>
> +my $rule_return_properties = {
> + action => {
> + type => 'string',
> + },
> + comment => {
> + type => 'string',
> + optional => 1,
> + },
> + dest => {
> + type => 'string',
> + optional => 1,
> + },
> + dport => {
> + type => 'string',
> + optional => 1,
> + },
> + enable => {
> + type => 'integer',
> + optional => 1,
> + },
> + log => PVE::Firewall::get_standard_option(
> + 'pve-fw-loglevel',
> + {
> + description => 'Log level for firewall rule',
> + },
> + ),
> + 'icmp-type' => {
> + type => 'string',
> + optional => 1,
> + },
> + iface => {
> + type => 'string',
> + optional => 1,
> + },
> + ipversion => {
> + type => 'integer',
> + optional => 1,
> + },
> + macro => {
> + type => 'string',
> + optional => 1,
> + },
> + pos => {
> + type => 'integer',
> + },
> + proto => {
> + type => 'string',
> + optional => 1,
> + },
> + source => {
> + type => 'string',
> + optional => 1,
> + },
> + sport => {
> + type => 'string',
> + optional => 1,
> + },
> + type => {
> + type => 'string',
> + },
> +};
> +
> =head3 check_privileges_for_method($class, $method_name, $param)
>
> If the permission checks from the register_method() call are not sufficient,
> @@ -102,11 +164,7 @@ sub register_get_rules {
> type => 'array',
> items => {
> type => "object",
> - properties => {
> - pos => {
> - type => 'integer',
> - },
> - },
> + properties => $rule_return_properties,
> },
> links => [{ rel => 'child', href => "{pos}" }],
> },
> @@ -151,67 +209,7 @@ sub register_get_rule {
> proxyto => $rule_env eq 'host' ? 'node' : undef,
> returns => {
> type => "object",
> - properties => {
> - action => {
> - type => 'string',
> - },
> - comment => {
> - type => 'string',
> - optional => 1,
> - },
> - dest => {
> - type => 'string',
> - optional => 1,
> - },
> - dport => {
> - type => 'string',
> - optional => 1,
> - },
> - enable => {
> - type => 'integer',
> - optional => 1,
> - },
> - log => PVE::Firewall::get_standard_option(
> - 'pve-fw-loglevel',
> - {
> - description => 'Log level for firewall rule',
> - },
> - ),
> - 'icmp-type' => {
> - type => 'string',
> - optional => 1,
> - },
> - iface => {
> - type => 'string',
> - optional => 1,
> - },
> - ipversion => {
> - type => 'integer',
> - optional => 1,
> - },
> - macro => {
> - type => 'string',
> - optional => 1,
> - },
> - pos => {
> - type => 'integer',
> - },
> - proto => {
> - type => 'string',
> - optional => 1,
> - },
> - source => {
> - type => 'string',
> - optional => 1,
> - },
> - sport => {
> - type => 'string',
> - optional => 1,
> - },
> - type => {
> - type => 'string',
> - },
> - },
> + properties => $rule_return_properties,
> },
> code => sub {
> my ($param) = @_;
> --
> 2.47.3
More information about the pve-devel
mailing list