Freeside:4:Documentation:Developer/FS/domain record

From Freeside
< Freeside:4:Documentation:Developer‎ | FS
Revision as of 08:22, 18 November 2015 by Jeremyd (talk | contribs) (Edit via perl MediaWiki framework (1.13))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


FS::domain_record - Object methods for domain_record records


 use FS::domain_record;

 $record = new FS::domain_record \%hash;
 $record = new FS::domain_record { 'column' => 'value' };

 $error = $record->insert;

 $error = $new_record->replace($old_record);

 $error = $record->delete;

 $error = $record->check;


An FS::domain_record object represents an entry in a DNS zone. FS::domain_record inherits from FS::Record. The following fields are currently supported:

recnum - primary key; svcnum - Domain (see FS::svc_domain) of this entry; reczone - partial (or full) zone for this entry; recaf - address family for this entry, currently only `IN' is recognized.; rectype - record type for this entry (A, MX, etc.); recdata - data for this entry; ttl - time to live


Creates a new entry. To add the entry to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
Delete this record from the database.
replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
Checks all fields to make sure this is a valid entry. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
increment_serial; svc_domain
Returns the domain (see FS::svc_domain) for this record.
Returns the canonical zone name.
Returns the corresponding reverse-ARPA record as another FS::domain_record object. If the specific record does not exist in the database but the reverse-ARPA zone itself does, an appropriate new record is created. If no reverse-ARPA zone is available at all, returns false.
(You can test whether or not record itself exists in the database or is a new object that might need to be inserted by checking the recnum field)
Mostly used by the insert and delete methods - probably should see them for examples.


The data validation doesn't check everything it could. In particular, there is no protection against bad data that passes the regex, duplicate SOA records, forgetting the trailing `.', impossible IP addersses, etc. Of course, it's still better than editing the zone files directly. :)


FS::Record, schema.html from the base documentation.