+sub register_read_ip {
+ my ($class) = @_;
+
+ my $properties = $class->additional_parameters();
+
+ $properties->{name} = $api_properties->{name};
+ $properties->{cidr} = $api_properties->{cidr};
+
+ $class->register_method({
+ name => 'read_ip',
+ path => '{cidr}',
+ method => 'GET',
+ description => "Read IP or Network settings from IPSet.",
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => $properties,
+ },
+ returns => { type => "object" },
+ code => sub {
+ my ($param) = @_;
+
+ my ($fw_conf, $ipset) = $class->load_config($param);
+
+ foreach my $entry (@$ipset) {
+ return $entry if $entry->{cidr} eq $param->{cidr};
+ }
+
+ raise_param_exc({ cidr => "no such IP/Network" });
+ }});
+}
+
+sub register_update_ip {
+ my ($class) = @_;
+
+ my $properties = $class->additional_parameters();
+
+ $properties->{name} = $api_properties->{name};
+ $properties->{cidr} = $api_properties->{cidr};
+ $properties->{nomatch} = $api_properties->{nomatch};
+ $properties->{comment} = $api_properties->{comment};
+
+ $class->register_method({
+ name => 'update_ip',
+ path => '{cidr}',
+ method => 'PUT',
+ description => "Update IP or Network settings",
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => $properties,
+ },
+ returns => { type => "null" },
+ code => sub {
+ my ($param) = @_;
+
+ my ($fw_conf, $ipset) = $class->load_config($param);
+
+ foreach my $entry (@$ipset) {
+ if($entry->{cidr} eq $param->{cidr}) {
+ $entry->{nomatch} = $param->{nomatch};
+ $entry->{comment} = $param->{comment};
+ $class->save_ipset($param, $fw_conf, $ipset);
+ return;
+ }
+ }
+
+ raise_param_exc({ cidr => "no such IP/Network" });
+ }});
+}
+
+sub register_delete_ip {