File Coverage

blib/lib/WWW/VastAI.pm
Criterion Covered Total %
statement 52 52 100.0
branch n/a
condition n/a
subroutine 26 26 100.0
pod n/a
total 78 78 100.0


line stmt bran cond sub pod time code
1             package WWW::VastAI;
2              
3             # ABSTRACT: Perl client for the Vast.ai REST APIs
4              
5 10     10   994183 use Moo;
  10         36094  
  10         64  
6 10     10   14739 use WWW::VastAI::API::APIKeys;
  10         44  
  10         476  
7 10     10   5974 use WWW::VastAI::API::Endpoints;
  10         42  
  10         390  
8 10     10   5761 use WWW::VastAI::API::EnvVars;
  10         70  
  10         475  
9 10     10   5823 use WWW::VastAI::API::Instances;
  10         49  
  10         465  
10 10     10   5805 use WWW::VastAI::API::Invoices;
  10         44  
  10         402  
11 10     10   6036 use WWW::VastAI::API::Offers;
  10         42  
  10         396  
12 10     10   5411 use WWW::VastAI::API::SSHKeys;
  10         60  
  10         465  
13 10     10   5686 use WWW::VastAI::API::Templates;
  10         43  
  10         449  
14 10     10   5365 use WWW::VastAI::API::User;
  10         46  
  10         430  
15 10     10   5639 use WWW::VastAI::API::Volumes;
  10         43  
  10         404  
16 10     10   5779 use WWW::VastAI::API::Workergroups;
  10         43  
  10         425  
17 10     10   70 use namespace::clean;
  10         18  
  10         49  
18              
19             our $VERSION = '0.001';
20              
21             has api_key => (
22             is => 'ro',
23             default => sub { $ENV{VAST_API_KEY} },
24             );
25              
26             has console_url => (
27             is => 'ro',
28             default => sub { 'https://console.vast.ai' },
29             );
30              
31             has base_url => (
32             is => 'lazy',
33 7     7   1146 builder => sub { shift->console_url . '/api/v0' },
34             );
35              
36             has base_url_v1 => (
37             is => 'lazy',
38 2     2   34 builder => sub { shift->console_url . '/api/v1' },
39             );
40              
41             has run_url => (
42             is => 'ro',
43             default => sub { 'https://run.vast.ai' },
44             );
45              
46             with 'WWW::VastAI::Role::HTTP', 'WWW::VastAI::Role::OperationMap';
47              
48             has offers => (
49             is => 'lazy',
50 1     1   32 builder => sub { WWW::VastAI::API::Offers->new(client => shift) },
51             );
52              
53             has instances => (
54             is => 'lazy',
55 3     3   92 builder => sub { WWW::VastAI::API::Instances->new(client => shift) },
56             );
57              
58             has templates => (
59             is => 'lazy',
60 1     1   53 builder => sub { WWW::VastAI::API::Templates->new(client => shift) },
61             );
62              
63             has volumes => (
64             is => 'lazy',
65 1     1   55 builder => sub { WWW::VastAI::API::Volumes->new(client => shift) },
66             );
67              
68             has ssh_keys => (
69             is => 'lazy',
70 1     1   49 builder => sub { WWW::VastAI::API::SSHKeys->new(client => shift) },
71             );
72              
73             has api_keys => (
74             is => 'lazy',
75 1     1   23 builder => sub { WWW::VastAI::API::APIKeys->new(client => shift) },
76             );
77              
78             has user => (
79             is => 'lazy',
80 1     1   22 builder => sub { WWW::VastAI::API::User->new(client => shift) },
81             );
82              
83             has env_vars => (
84             is => 'lazy',
85 1     1   24 builder => sub { WWW::VastAI::API::EnvVars->new(client => shift) },
86             );
87              
88             has invoices => (
89             is => 'lazy',
90 1     1   24 builder => sub { WWW::VastAI::API::Invoices->new(client => shift) },
91             );
92              
93             has endpoints => (
94             is => 'lazy',
95 1     1   137 builder => sub { WWW::VastAI::API::Endpoints->new(client => shift) },
96             );
97              
98             has workergroups => (
99             is => 'lazy',
100 1     1   25 builder => sub { WWW::VastAI::API::Workergroups->new(client => shift) },
101             );
102              
103             1;
104              
105             __END__