Net::Whois::Object - Object encapsulating RPSL data returned by Whois queries
use Net::Whois::RIPE; use Net::Whois::Object; my $whois = Net::Whois::RIPE->new( %options ); $iterator = $whois->query('AS30781'); push @objects, Net::Whois::Object->new($iterator); for my $object (@objects) { # process the Net::Whois::Object::xxx objects... # Type of object is available via class() method }
# Get the Class we want to modify my $whois = Net::Whois::RIPE->new( %options ); $iterator = $whois->query('POLK-RIPE');
Currently the only crude way to filter objects is to use the class() method.
# To only get the Person object (and ignore the Information objects) my ($person) = grep {$_->class() eq 'Person'} Net::Whois::Object->new($iterator);
# Add a phone number $person->phone(' +33 4 88 00 65 15')
The dump() method, permit to print the object under the classic text form, made of 'attribute: value' lines. This may seem useless now, but will come handy to make update through email.
# Dump the modified data my $to_be_mailed = $person->dump();
The RIPE database update is currently under heavy development. *The update code is to be considered as experimental.*
We plan to offer several ways to update the RIPE database
RIPE provides several web interfaces
Although not the latest one, this simple interface is the first to be wrapped by this module.
CAUTION: SyncUpdates features require LWP::UserAgent to be installed.
Once the object has been modified, locally, you can create it in the database calling the syncupdates_create() method. The only parameter being the associated maintener's authentication as a password or pgp key:
$object->person('John Doe'); ... my $primary_key = $object->syncupdates_create({ password => $password }); # or my $primary_key = $object->syncupdates_create({ pgpkey => $pgpkey });
The pgp key must be an eight digit hexadecimal key ID known to the local gpg executable.
gpg
If the pgpkey key is present in the hash reference passed to syncupdates_create, you can also pass in the pgpexec key to chose a program to execute for signing (gpg by default), and pgpopts, which must be an array reference of additional options to pass to the signing binary.
pgpkey
pgpexec
pgpopts
For backwards compatibility, the password can be passed directly without using a a hash reference, $object->syncupdates_create($password).
$object->syncupdates_create($password)
The primary key of the object created is returned. The attribute used as primary key can be obtained through $object->attribute('primary')
An object existing in the RIPE database, can be retrived, modified locally and the updated through the syncupdates_update() method. The only parameter being the associated maintener's authentication. See "Create" for more information on the authentication methods.
$object->person('John Doe'); ... $object->syncupdates_update($auth);
An object existing in the RIPE database, can be retrived, and deleted in the databased through the syncupdates_delete() method. The only required parameter being the associated maintener's authentication. See "Create" for more information on the authentication methods.
$object->syncupdates_update($auth);
An additional parameter can be used as a reason for the deletion.
$object->syncupdates_update($auth,'Obsoleted by XXX');
If no reason is provided, a default one ('Not needed anymore') is used.
Not implemented yet.
The constructor is a factory returning the appropriate Net::Whois::Objects based on the first attribute of the block. You can pass an array of lines or an iterator returned by Net::Whois::RIPE as argument.
The two following ways of using the constructor are possible
my $whois = Net::Whois::RIPE->new( %options ); $iterator = $whois->query('AS30781'); # Using the iterator way push @objects, Net::Whois::Object->new($iterator);
or
# Using the previous (more circonvoluted) @lines way while ( ! $iterator->is_exhausted() ) { my @lines = map { "$_\n"} split '\n', $iterator->value(); push @objects, Net::Whois::Object->new(@lines,"\n"); }
Accessor to the attributes of the object. $type can be
'primary' Primary/Lookup key 'mandatory' Required for update creation 'optional' Optionnal for update/creation 'multiple' Can have multiple values 'single' Have only one value 'all' You can't specify attributes for this special type which provides all the attributes which have a type
If no $type is specified, 'all' is assumed. Returns a list of attributes of the required type.
This method return the RIPE class associated to the current object.
This method return true if $attribute is of type $type.
Accessor to the filtered_attributes attribute (attributes to be hidden) Accepts an optional attribute to be added to the filtered_attributes array, always return the current filtered_attributes array.
Accessor to the displayed_attributes attribute which should be displayed. Accepts an optional attribute to be added to the displayed_attributes array, always return the current displayed_attributes array.
Simple naive way to display a text form of the class. Try to be as close as possible as the submited text.
Update the RIPE database through the web syncupdates interface. Use the password passed as parameter to authenticate.
Delete the object in the RIPE database through the web syncupdates interface. Use the password passed as parameter to authenticate. The optional parmeter reason is used to explain why the object is deleted.
Create an object in the the RIPE database through the web syncupdates interface. See "Create" for possible values of $auth.
$auth
Return the primary key of the object created.
The update part (in RIPE database) still needs a lot of work.
Arnaud "Arhuman" Assad, <arhuman at gmail.com>
<arhuman at gmail.com>
Thanks to Jaguar Network for allowing me to work on this during some of my office hours.
Thanks to Luis Motta Campos for his trust when allowing me to publish this release.
Thanks to Moritz Lenz for all his contributions (Thanks also to 'Noris Network AG', his employer, for allowing him to contribute in the office hours)
To install Net::Whois::RIPE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Whois::RIPE
CPAN shell
perl -MCPAN -e shell install Net::Whois::RIPE
For more information on module installation, please visit the detailed CPAN module installation guide.