The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Whois::Object - Object encapsulating RPSL data returned by Whois queries

SYNOPSIS

    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
    }

USAGE

Get the data

    # Get the Class we want to modify
    my $whois = Net::Whois::RIPE->new( %options );
    $iterator = $whois->query('POLK-RIPE');

Filter the objects

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);

Modify the data

    # Add a phone number
    $person->phone(' +33 4 88 00 65 15')

Dump the current state of the data

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();

Update the RIPE database

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

Update through the web interface.

RIPE provides several web interfaces

SyncUpdates (*Experimental*)

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.

Create

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.

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.

For backwards compatibility, the password can be passed directly without using a a hash reference, $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')

Update

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);

Delete

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.

Update through email.

Not implemented yet.

SUBROUTINES/METHODS

new( @lines|$iterator )

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");
    }

attributes( [$type [, \@attributes]] )

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.

class ( )

This method return the RIPE class associated to the current object.

attribute_is ( $attribute, $type )

This method return true if $attribute is of type $type.

hidden_attributes( $attribute )

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.

displayed_attributes( $attribute )

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.

dump( )

Simple naive way to display a text form of the class. Try to be as close as possible as the submited text.

syncupdates_update( $password )

Update the RIPE database through the web syncupdates interface. Use the password passed as parameter to authenticate.

syncupdates_delete( $password, [$reason] )

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.

syncupdates_create( $auth )

Create an object in the the RIPE database through the web syncupdates interface. See "Create" for possible values of $auth.

Return the primary key of the object created.

TODO

The update part (in RIPE database) still needs a lot of work.

AUTHOR

Arnaud "Arhuman" Assad, <arhuman at gmail.com>

ACKNOWLEDGEMENTS

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)