From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-firewall] api: rules: add return type to list_rules endpoint
Date: Wed, 22 Oct 2025 13:17:37 +0200 [thread overview]
Message-ID: <20251022111737.190009-1-h.laimer@proxmox.com> (raw)
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@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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2025-10-22 11:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 11:17 Hannes Laimer [this message]
2025-10-22 14:38 ` [pve-devel] applied: " Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251022111737.190009-1-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox