API-Vultr
view release on metacpan or search on metacpan
1617181920212223242526272829303132333435363738394041424344454647484950515253545556"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"
: {
},
"license"
: [
],
"repository"
: {
"type"
:
"git"
,
}
123456789101112131415161718192021222324252627282930313233---
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:
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
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
6789101112131415161718192021222324252627WriteMakefile(
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
=>
license
=>
repository
=> {
type
=>
'git'
,
}
},
},
678910111213141516171819202122232425262728293031323334353637Please
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;
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) {
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.
lib/API/Vultr.pm view on Meta::CPAN
249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282extendible 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
3637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
"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,
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,
( run in 1.855 second using v1.01-cache-2.11-cpan-87723dcf8b7 )