API-Vultr
view release on metacpan or search on metacpan
"no_index" : {
"directory" : [
"t",
"inc",
"examples",
"t"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"LWP::UserAgent" : "6.72",
"Test::LWP::UserAgent" : "0.036",
"Test::Simple" : "1.302195",
"URI" : "5.21",
"perl" : "v5.8.1"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/rawleyfowler/API-Vultr/issues"
},
"license" : [
"http://www.opensource.org/licenses/artistic-license-2.0"
],
"repository" : {
"type" : "git",
"url" : "https://github.com/rawleyfowler/API-Vultr"
}
---
abstract: 'A simple interface to the Vultr v2 API'
author:
- unknown
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: API-Vultr
no_index:
directory:
- t
- inc
- examples
- t
requires:
LWP::UserAgent: '6.72'
Test::LWP::UserAgent: '0.036'
Test::Simple: '1.302195'
URI: '5.21'
perl: v5.8.1
resources:
bugtracker: https://github.com/rawleyfowler/API-Vultr/issues
license: http://www.opensource.org/licenses/artistic-license-2.0
repository: https://github.com/rawleyfowler/API-Vultr
version: '0.003'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
WriteMakefile(
NAME => 'API::Vultr',
VERSION_FROM => 'lib/API/Vultr.pm',
ABSTRACT => qq{A simple interface to the Vultr v2 API},
license => 'artistic_2',
META_MERGE => {
dynamic_config => 0,
'meta-spec' => { version => 2 },
no_index => { directory => [ 'examples', 't' ] },
prereqs => { runtime => { requires => { perl => 'v5.8.1' } } },
resources => {
bugtracker =>
{ web => 'https://github.com/rawleyfowler/API-Vultr/issues' },
license =>
[qq{http://www.opensource.org/licenses/artistic-license-2.0}],
repository => {
type => 'git',
url => 'https://github.com/rawleyfowler/API-Vultr'
}
},
},
Please read the `POD` associated with `API::Vultr`, and the [Vultr API](https://vultr.com/api) to get a better understanding of all of the
available methods.
```perl
use API::Vultr;
use Data::Dumper qw(Dumper);
my $vultr_api = API::Vultr->new(api_key => $ENV{VULTR_API_KEY});
my $create_response = $vultr_api->create_instance(
region => 'ewr',
plan => 'vc2-6c-16gb',
label => 'My Instance',
os_id => 215,
user_data => 'QmFzZTY4EVsw32WfsGGHsjKJI',
backups => 'enabled',
hostname => 'hostname'
);
if ($create_response->is_success) {
print Dumper($create_response->decoded_content);
}
else {
die $create_response->status_line;
}
```
## License
This project is licensed under the Artistic 2.0 license. Please read the `LICENSE` file at the root of the
project for more information on what that means.
use strict;
use warnings;
on "configure" => sub {
requires "ExtUtils::MakeMaker";
};
on "runtime" => sub {
requires "LWP::UserAgent" => "6.72";
};
on "test" => sub {
requires "Test::Simple";
requires "Test::LWP::UserAgent";
};
lib/API/Vultr.pm view on Meta::CPAN
extendible allowing for easy contributions. Basically, I have what I need,
if you need more feel free to add it!
=head1 Example
use API::Vultr;
use Data::Dumper qw(Dumper);
my $vultr_api = API::Vultr->new(api_key => $ENV{VULTR_API_KEY});
my $create_response = $vultr_api->create_instance(
region => 'ewr',
plan => 'vc2-6c-16gb',
label => 'My Instance',
os_id => 215,
user_data => 'QmFzZTY4EVsw32WfsGGHsjKJI',
backups => 'enabled',
hostname => 'hostname'
);
if ($create_response->is_success) {
print Dumper($create_response->decoded_content);
}
else {
die $create_response->status_line;
}
=head1 API
=head2 ua
Set, or get the L<LWP::UserAgent> associated L<API::Vultr> instance.
=head2 api_key
t/01-test.t view on Meta::CPAN
"name": "LEMP",
"short_name": "lemp",
"deploy_name": "LEMP on CentOS 6 x64",
"type": "one-click",
"vendor": "vultr",
"image_id": ""
},
{
"id": 1028,
"name": "OpenLiteSpeed WordPress",
"short_name": "openlitespeedwordpress",
"deploy_name": "OpenLiteSpeed WordPress on Ubuntu 20.04 x64",
"type": "marketplace",
"vendor": "LiteSpeed_Technologies",
"image_id": "openlitespeed-wordpress"
}
],
"meta":
{
"total": 2,
"links":
{
"next": "",
"prev": ""
}
}
}';
$vultr_api->ua->map_response(
qr{api.vultr.com/v2/applications},
HTTP::Response->new(
'200', 'OK',
[ 'Content-Type' => 'application/json' ], $application_json
)
);
ok $vultr_api->get_applications->is_success;
ok $vultr_api->get_applications->decoded_content, $application_json;
ok $vultr_api->ua->last_http_request_sent;
is $vultr_api->ua->last_http_request_sent->header('Authorization'),
'Bearer 123';
is $vultr_api->ua->last_http_request_sent->uri,
'https://api.vultr.com/v2/applications';
ok $vultr_api->ua->last_http_response_received->is_success;
is $vultr_api->ua->last_http_response_received->decoded_content,
$application_json;
$vultr_api->ua->map_response(
qr{api.vultr.com/v2/instances},
HTTP::Response->new(
'200', 'OK',
[ 'Content-Type' => 'application/json' ], $application_json
)
);
ok $vultr_api->create_instance( name => 'foo' )->is_success;
is $vultr_api->ua->last_http_request_sent->uri,
'https://api.vultr.com/v2/instances';
( run in 1.110 second using v1.01-cache-2.11-cpan-49f99fa48dc )