https://github.com/ccakes/megaport-perl
Simple Perl interface to the Megaport API
https://github.com/ccakes/megaport-perl
Last synced: 5 months ago
JSON representation
Simple Perl interface to the Megaport API
- Host: GitHub
- URL: https://github.com/ccakes/megaport-perl
- Owner: ccakes
- License: mit
- Created: 2017-03-08T12:23:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-08T22:03:35.000Z (over 9 years ago)
- Last Synced: 2024-12-30T14:56:36.485Z (over 1 year ago)
- Language: Perl
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/ccakes/megaport-perl) [](https://metacpan.org/release/Megaport)
Megaport - Simple access to the [Megaport](https://www.megaport.com) API
# SYNOPSIS
use Megaport;
# Using an existing session token
my $mp = Megaport->new(token => 'your-session-token');
# Using a username/password combo
my $mp = Megaport->new(username => 'me@example.com', password => 's3cr3t');
# Get a list of locations (on-net datacentres)
my @locations = $mp->session->locations->list;
# Get a partial list
my @locations = $mp->session->locations->list(country => 'Australia');
my @locations = $mp->session->locations->list(name => qr/^Digital Realty/);
# Get a single entry
my $global_switch = $mp->session->locations->get(id => 3);
# Services
my $services = $mp->session->services;
$services->list(...);
$services->get(...);
# Other Megaports on the network
my $ports = $mp->session->ports;
$ports->list(...);
# DESCRIPTION
This module provides a Perl interface to the [Megaport](https://www.megaport.com) API. This is largely to fill my own requirements and for now is read only. Read/write functionality will be added over time to support service modification.
# METHODS
## new
my $mp = Megaport->new(
token => 'your-session-token',
uri => 'https://api.megaport.com/v2',
debug => 0,
no_verify => 0
);
The fields `token`, `username` and `password` are all auth relatated and should be fairly self explanatory. If you're unsure about token, take a look at the [Megaport docs](https://dev.megaport.com/#security).
`debug` enables extra output to STDERR during API calls. [Megaport::Client](https://metacpan.org/pod/Megaport::Client) by default will validate the token or user credentials by making a POST call to the Megaport API, set `no_verify` to stop this and speed things up.
As at this writing, the production Megaport API is at https://api.megaport.com with a test environment mentioned in the documentation at https://api-staging.megaport.com. If you wish to change environments, set `uri`.
## session
my $session = $mp->session;
Returns a [Megaport::Session](https://metacpan.org/pod/Megaport::Session) object which contains an authenticated client ready to start making calls.
# TODO
- Module/helper for per-service type to make data access easier
- Dig into VXCs/IX from top level service
- Access pricing/cost estimate info per service
- Simple service modification, speed/VLAN etc
- Helper method to link partner ports and location to make searching by city/country/region easier
- Company object with access to users, invoices and outstanding balance
# AUTHOR
Cameron Daniel