line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VMware::vCloudDirector; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Interface to VMWare vCloud Directory REST API |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
48771
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
78
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; # VERSION |
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
816
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Method::Signatures; |
13
|
|
|
|
|
|
|
use MooseX::Types::Path::Tiny qw/Path/; |
14
|
|
|
|
|
|
|
use Path::Tiny; |
15
|
|
|
|
|
|
|
use VMware::vCloudDirector::API; |
16
|
|
|
|
|
|
|
use VMware::vCloudDirector::Error; |
17
|
|
|
|
|
|
|
use VMware::vCloudDirector::Object; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has debug => ( is => 'rw', isa => 'Bool', default => 0 ); # Defaults to no debug info |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has hostname => ( is => 'ro', isa => 'Str', required => 1 ); |
25
|
|
|
|
|
|
|
has username => ( is => 'ro', isa => 'Str', required => 1 ); |
26
|
|
|
|
|
|
|
has password => ( is => 'ro', isa => 'Str', required => 1 ); |
27
|
|
|
|
|
|
|
has orgname => ( is => 'ro', isa => 'Str', required => 1, default => 'System' ); |
28
|
|
|
|
|
|
|
has ssl_verify => ( is => 'ro', isa => 'Bool', predicate => '_has_ssl_verify' ); |
29
|
|
|
|
|
|
|
has timeout => ( is => 'rw', isa => 'Int', predicate => '_has_timeout' ); |
30
|
|
|
|
|
|
|
has ssl_ca_file => ( is => 'ro', isa => Path, coerce => 1, predicate => '_has_ssl_ca_file' ); |
31
|
|
|
|
|
|
|
has _ua => ( is => 'ro', isa => 'LWP::UserAgent', predicate => '_has_ua' ); |
32
|
|
|
|
|
|
|
has _debug_trace_directory => |
33
|
|
|
|
|
|
|
( is => 'ro', isa => Path, coerce => 1, predicate => '_has_debug_trace_directory' ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has api => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => 'VMware::vCloudDirector::API', |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
builder => '_build_api' |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
method _build_api () { |
43
|
|
|
|
|
|
|
my @args = ( |
44
|
|
|
|
|
|
|
hostname => $self->hostname, |
45
|
|
|
|
|
|
|
username => $self->username, |
46
|
|
|
|
|
|
|
password => $self->password, |
47
|
|
|
|
|
|
|
orgname => $self->orgname, |
48
|
|
|
|
|
|
|
debug => $self->debug |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
push( @args, timeout => $self->timeout ) if ( $self->_has_timeout ); |
51
|
|
|
|
|
|
|
push( @args, ssl_verify => $self->ssl_verify ) if ( $self->_has_ssl_verify ); |
52
|
|
|
|
|
|
|
push( @args, ssl_ca_file => $self->ssl_ca_file ) if ( $self->_has_ssl_ca_file ); |
53
|
|
|
|
|
|
|
push( @args, _debug_trace_directory => $self->_debug_trace_directory ) |
54
|
|
|
|
|
|
|
if ( $self->_has_debug_trace_directory ); |
55
|
|
|
|
|
|
|
push( @args, _ua => $self->_ua ) if ( $self->_has_ua ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return VMware::vCloudDirector::API->new(@args); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
has org_listref => ( |
62
|
|
|
|
|
|
|
is => 'ro', |
63
|
|
|
|
|
|
|
isa => 'ArrayRef[VMware::vCloudDirector::Object]', |
64
|
|
|
|
|
|
|
lazy => 1, |
65
|
|
|
|
|
|
|
builder => '_build_org_listref', |
66
|
|
|
|
|
|
|
traits => ['Array'], |
67
|
|
|
|
|
|
|
handles => { |
68
|
|
|
|
|
|
|
org_list => 'elements', |
69
|
|
|
|
|
|
|
org_map => 'map', |
70
|
|
|
|
|
|
|
org_grep => 'grep', |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
method _build_org_listref { return [ $self->api->GET('/api/org/') ]; } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
76
|
|
|
|
|
|
|
method query (@args) { |
77
|
|
|
|
|
|
|
my $uri = $self->api->query_uri->clone; |
78
|
|
|
|
|
|
|
$uri->query_form(@args); |
79
|
|
|
|
|
|
|
return $self->api->GET($uri); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |