API-Vultr

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"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",
   }

META.yml  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
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:
version: '0.003'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 =>
            repository => {
                type => 'git',
                url  => 'https://github.com/rawleyfowler/API-Vultr'
            }
        },
    },

README.md  view on Meta::CPAN

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 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.

cpanfile  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict;
 
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

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    "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 )