[pmg-devel] [PATCH pmg-api 7/8] feature: match groups: update API endpoints

Leo Nunner l.nunner at proxmox.com
Fri Apr 7 15:42:53 CEST 2023


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 at 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





More information about the pmg-devel mailing list