[pmg-devel] [PATCH WIP api 10/11] match groups: update existing object API endpoints

Leo Nunner l.nunner at proxmox.com
Thu Sep 14 11:52:31 CEST 2023


Adds a 'group' parameter to all relevant endpoints, which enables
associating objects inside rules with given match groups.
---
 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 91e91ed..ba86ede 100644
--- a/src/PMG/API2/Rules.pm
+++ b/src/PMG/API2/Rules.pm
@@ -347,6 +347,11 @@ my $register_rule_group_api = sub {
 		    type => 'boolean',
 		    optional => 1,
 		},
+		'group' => {
+		    description => "Add to match group.",
+		    type => 'integer',
+		    optional => 1,
+		},
 	    },
 	},
 	returns => { type => 'null' },
@@ -363,6 +368,10 @@ my $register_rule_group_api = sub {
 		$rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name);
 	    }
 
+	    if (defined($param->{group})) {
+		$rdb->rule_set_group_setting_matchgroup($param->{group}, $param->{id}, $param->{ogroup}, $name);
+	    }
+
 	    PMG::DBTools::reload_ruledb();
 
 	    return undef;
@@ -435,6 +444,10 @@ my $register_rule_group_api = sub {
 				description=>  "Negate group.",
 				type => 'boolean',
 			    },
+			    'group' => {
+				description=>  "Match group ID.",
+				type => 'integer',
+			    }
 			}
 		    }
 		},
@@ -447,6 +460,7 @@ my $register_rule_group_api = sub {
 
 		    my $ret = {
 			negate => $settings->{negate},
+			'group' => $settings->{matchgroup},
 		    };
 
 		    return $ret;
@@ -476,6 +490,11 @@ my $register_rule_group_api = sub {
 			    type => 'boolean',
 			    optional => 1,
 			},
+			'group' => {
+			    description => "Add to match group.",
+			    type => 'integer',
+			    optional => 1,
+			},
 		    },
 		},
 		returns => { type => 'null' },
@@ -488,6 +507,10 @@ my $register_rule_group_api = sub {
 			$rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name);
 		    }
 
+		    if(defined($param->{group})) {
+			$rdb->rule_set_group_setting_matchgroup($param->{group}, $param->{id}, $param->{ogroup}, $name);
+		    }
+
 		    return;
 		}});
     }
-- 
2.39.2





More information about the pmg-devel mailing list