7fb7db5e511868a69198183bc04b6dea7b09149b
[freeside.git] / FS / FS / nas.pm
1 package FS::nas;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::nas - Object methods for nas records
10
11 =head1 SYNOPSIS
12
13   use FS::nas;
14
15   $record = new FS::nas \%hash;
16   $record = new FS::nas { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::nas object represents a RADIUS client.  FS::nas inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item nasnum
34
35 primary key
36
37 =item nasname
38
39 nasname
40
41 =item shortname
42
43 shortname
44
45 =item type
46
47 type
48
49 =item ports
50
51 ports
52
53 =item secret
54
55 secret
56
57 =item server
58
59 server
60
61 =item community
62
63 community
64
65 =item description
66
67 description
68
69
70 =back
71
72 =head1 METHODS
73
74 =over 4
75
76 =item new HASHREF
77
78 Creates a new NAS.  To add the NAS to the database, see L<"insert">.
79
80 Note that this stores the hash reference, not a distinct copy of the hash it
81 points to.  You can ask the object for a copy with the I<hash> method.
82
83 =cut
84
85 # the new method can be inherited from FS::Record, if a table method is defined
86
87 sub table { 'nas'; }
88
89 =item insert
90
91 Adds this record to the database.  If there is an error, returns the error,
92 otherwise returns false.
93
94 =cut
95
96 # the insert method can be inherited from FS::Record
97
98 =item delete
99
100 Delete this record from the database.
101
102 =cut
103
104 # the delete method can be inherited from FS::Record
105
106 =item replace OLD_RECORD
107
108 Replaces the OLD_RECORD with this one in the database.  If there is an error,
109 returns the error, otherwise returns false.
110
111 =cut
112
113 # the replace method can be inherited from FS::Record
114
115 =item check
116
117 Checks all fields to make sure this is a valid NAS.  If there is
118 an error, returns the error, otherwise returns false.  Called by the insert
119 and replace methods.
120
121 =cut
122
123 # the check method should currently be supplied - FS::Record contains some
124 # data checking routines
125
126 sub check {
127   my $self = shift;
128
129   my $error = 
130     $self->ut_numbern('nasnum')
131     || $self->ut_text('nasname')
132     || $self->ut_textn('shortname')
133     || $self->ut_text('type')
134     || $self->ut_numbern('ports')
135     || $self->ut_text('secret')
136     || $self->ut_textn('server')
137     || $self->ut_textn('community')
138     || $self->ut_text('description')
139   ;
140   return $error if $error;
141
142   $self->SUPER::check;
143 }
144
145 =back
146
147 =head1 BUGS
148
149 =head1 SEE ALSO
150
151 L<FS::Record>, schema.html from the base documentation.
152
153 =cut
154
155 1;
156