]> git.proxmox.com Git - pmg-api.git/blame - PMG/RuleDB/Rule.pm
fix schema definition
[pmg-api.git] / PMG / RuleDB / Rule.pm
CommitLineData
0a580593
DM
1package PMG::RuleDB::Rule;
2
3use strict;
4use warnings;
5use DBI;
6
7use PMG::RuleDB;
8
9# FIXME: log failures ?
10
11sub new {
12 my ($type, $name, $priority, $active, $direction) = @_;
4a34322a 13
0a580593 14 my $self = {
4a34322a
DM
15 name => $name // '',
16 priority => $priority // 0,
17 active => $active // 0,
0a580593
DM
18 };
19
20 if (!defined($direction)) {
21 $self->{direction} = 2;
22 } else {
23 $self->{direction} = $direction;
24 }
25
26 bless $self, $type;
27
28 return $self;
29}
30
31sub name {
32 my ($self, $v) = @_;
33
34 if (defined ($v)) {
35 $self->{name} = $v;
36 }
37
38 $self->{name};
39}
40
41sub priority {
42 my ($self, $v) = @_;
43
44 if (defined ($v)) {
45 $self->{priority} = $v;
46 }
47
48 $self->{priority};
49}
50
51sub direction {
52 my ($self, $v) = @_;
53
54 if (defined ($v)) {
55 $self->{direction} = $v;
56 }
57
58 $self->{direction};
59}
60
61sub active {
62 my ($self, $v) = @_;
63
64 if (defined ($v)) {
65 $self->{active} = $v;
66 }
67
68 $self->{active};
69}
70
71sub id {
72 my $self = shift;
73
74 $self->{id};
75}
76
771;