The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Megaport::Internal::_Result - Parent class for arbitary resultsets

SYNOPSIS

    my $eq1 = $mp->session->locations->get(id => 2);
    say $eq1->name, $eq1->address->{street};

DESCRIPTION

This provides a simple but consistent interface to pull and present data from the Megaport API in a read-only manner. It fetches and caches the data on instantiation so repeated usage should be fairly responsive.

METHODS

list

    # Optional array or arrayref
    my @list = $locations->list;
    my $list = $locations->list;

    # Use search terms to find a partial list
    my @oceania = $locations->list(networkRegion => 'ANZ');
    my @uk = $locations->list(country => 'United Kingdom');

    # Or use a regexp to get a bit fancy
    my @dlr = $locations->list(name => qr/^Digital Realty/);

Returns a list or allows searching based on any field present in the object.

get

    my $gs = $locations->get(id => 3);
    my $sy3 = $locations->get(name => 'Equinix SY3');

Best used to search by id but as with "list" in list, any field can be used. This method uses "first" in List::Util to return the first matching entry. The data is stored in a hash internally so the keys are unordered. Using this method with a search term like country will yield unexpected results.

AUTHOR

Cameron Daniel <cdaniel@cpan.org>