public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Leo Nunner <l.nunner@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 7/8] feature: match groups: update API endpoints
Date: Fri,  7 Apr 2023 15:42:53 +0200	[thread overview]
Message-ID: <20230407134258.199691-8-l.nunner@proxmox.com> (raw)
In-Reply-To: <20230407134258.199691-1-l.nunner@proxmox.com>

Adds the 'and' parameter to all rule API endpoints. The conditional
endpoints from the 'negate' setting are still being used again here,
since we don't need this property for actions.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
 src/PMG/API2/Rules.pm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/PMG/API2/Rules.pm b/src/PMG/API2/Rules.pm
index ad3f6c7..4882c5a 100644
--- a/src/PMG/API2/Rules.pm
+++ b/src/PMG/API2/Rules.pm
@@ -266,6 +266,11 @@ my $register_rule_group_api = sub {
 		    type => 'boolean',
 		    optional => 1,
 		},
+		'and' => {
+		    description => "Add to logical AND list.",
+		    type => 'boolean',
+		    optional => 1,
+		},
 	    },
 	},
 	returns => { type => 'null' },
@@ -282,6 +287,10 @@ my $register_rule_group_api = sub {
 		$rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name);
 	    }
 
+	    if (defined($param->{and})) {
+		$rdb->rule_set_group_setting_matchgroup($param->{and}, $param->{id}, $param->{ogroup}, $name);
+	    }
+
 	    PMG::DBTools::reload_ruledb();
 
 	    return undef;
@@ -354,6 +363,10 @@ my $register_rule_group_api = sub {
 				description=>  "Negate group.",
 				type => 'boolean',
 			    },
+			    'and' => {
+				description=>  "In match group.",
+				type => 'boolean',
+			    }
 			}
 		    }
 		},
@@ -366,6 +379,7 @@ my $register_rule_group_api = sub {
 
 		    my $ret = {
 			negate => $settings->{negate},
+			'and' => $settings->{matchgroup},
 		    };
 
 		    return $ret;
@@ -395,6 +409,11 @@ my $register_rule_group_api = sub {
 			    type => 'boolean',
 			    optional => 1,
 			},
+			'and' => {
+			    description => "Add to logical AND list.",
+			    type => 'boolean',
+			    optional => 1,
+			},
 		    },
 		},
 		returns => { type => 'null' },
@@ -407,6 +426,10 @@ my $register_rule_group_api = sub {
 			$rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name);
 		    }
 
+		    if(defined($param->{and})) {
+			$rdb->rule_set_group_setting_matchgroup($param->{and}, $param->{id}, $param->{ogroup}, $name);
+		    }
+
 		    return;
 		}});
     }
-- 
2.30.2





  parent reply	other threads:[~2023-04-07 13:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-07 13:42 [pmg-devel] [PATCH pmg-api/gui/docs, proxmox-widget-toolkit] Extend rule system Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 1/8] feature: negation: add field to database Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 2/8] feature: negation: parse negation value into objects Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 3/8] feature: negation: expand/implement API endpoints Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 4/8] feature: negation: implement matching logic Leo Nunner
2023-04-11  7:35   ` Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 5/8] feature: match groups: add field to database Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 6/8] feature: match groups: parse field into objects Leo Nunner
2023-04-07 13:42 ` Leo Nunner [this message]
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-api 8/8] feature: match groups: implement matching logic Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-gui 1/2] feature: negate objects inside rules Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-gui 2/2] feature: introduce logical 'and' for rules Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH pmg-docs] docs: document negation and match groups Leo Nunner
2023-04-07 13:42 ` [pmg-devel] [PATCH widget-toolkit] dark-mode: fix colour of default tree icons Leo Nunner
2023-04-11  9:52 ` [pmg-devel] [PATCH pmg-api/gui/docs, proxmox-widget-toolkit] Extend rule system Thomas Lamprecht
2023-04-11 11:04   ` Leo Nunner
2023-04-11 11:19     ` Thomas Lamprecht

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=20230407134258.199691-8-l.nunner@proxmox.com \
    --to=l.nunner@proxmox.com \
    --cc=pmg-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal