| 1 | package VMware::vCloudDirector::Object; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Module to contain an object! | ||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '0.007'; # VERSION | |||||||||||||||||||||||||||||||||||||
| 9 | 4 | our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Method::Signatures; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Ref::Util qw(is_plain_hashref); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Lingua::EN::Inflexion; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use VMware::vCloudDirector::ObjectContent; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | 4 | has api => ( | |||||||||||||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 22 | isa => 'VMware::vCloudDirector::API', | ||||||||||||||||||||||||||||||||||||||
| 23 | required => 1, | ||||||||||||||||||||||||||||||||||||||
| 24 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||
| 25 | documentation => 'API we use' | ||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | 4 | has content => ( | |||||||||||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 30 | isa => 'VMware::vCloudDirector::ObjectContent', | ||||||||||||||||||||||||||||||||||||||
| 31 | predicate => 'has_content', | ||||||||||||||||||||||||||||||||||||||
| 32 | writer => '_set_content', | ||||||||||||||||||||||||||||||||||||||
| 33 | documentation => 'The underlying content object', | ||||||||||||||||||||||||||||||||||||||
| 34 | handles => [qw( mime_type href type name )], | ||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | 4 | has _partial_object => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | # delegates that force a full object to be pulled | ||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | method hash () { return $self->inflate->content->hash; } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
hash: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | method links () { return $self->inflate->content->links; } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
links: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | method id () { return $self->inflate->content->id; } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.1
Subroutine
id: not called CC=2 SCAR=12.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | method BUILD ($args) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
BUILD: called CC=3 SCAR=11.2
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | $self->_set_content( | ||||||||||||||||||||||||||||||||||||||
| 48 | 17 | VMware::vCloudDirector::ObjectContent->new( object => $self, hash => $args->{hash} ) ); | |||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | method inflate () { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
inflate: called CC=3 SCAR=11.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | $self->refetch if ( $self->_partial_object ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 56 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | method refetch () { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
refetch: called CC=4 SCAR=14.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 61 | 2 | my $hash = $self->api->GET_hash( $self->href ); | |||||||||||||||||||||||||||||||||||||
| 62 | 2 | $self->_set_content( | |||||||||||||||||||||||||||||||||||||
| 63 | VMware::vCloudDirector::ObjectContent->new( object => $self, hash => $hash ) ); | ||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | $self->api->_debug( | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 65 | sprintf( | ||||||||||||||||||||||||||||||||||||||
| 66 | 'Object: %s a [%s]', | ||||||||||||||||||||||||||||||||||||||
| 67 | ( $self->_partial_object ? 'Inflated' : 'Refetched' ), | ||||||||||||||||||||||||||||||||||||||
| 68 | $self->type | ||||||||||||||||||||||||||||||||||||||
| 69 | ) | ||||||||||||||||||||||||||||||||||||||
| 70 | ) if ( $self->api->debug ); | ||||||||||||||||||||||||||||||||||||||
| 71 | 2 | $self->_partial_object(0); | |||||||||||||||||||||||||||||||||||||
| 72 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | method find_links (:$name, :$type, :$rel) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
find_links: called CC=13 SCAR=27.3
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my @matched_links; | |||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $links = $self->links; | |||||||||||||||||||||||||||||||||||||
| 81 | 1 | foreach my $link ( @{$links} ) { | |||||||||||||||||||||||||||||||||||||
| 82 | 10 | ▶ | if ( not( defined($rel) ) or ( $rel eq ( $link->rel || '' ) ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not defined $rel or $rel eq ($link->rel || "")
$link->rel || ''
MC/DC50%1/2
not defined $rel or $rel eq ($link->rel || "")
not defined $rel
$rel eq ($link->rel || "")
MC/DC0%0/1
$link->rel || ''
$link->rel
Truth table66%2/3
not(A) or B
A= not defined $relB= $rel eq ($link->rel || "")
Truth table50%1/2
A
A= $link->rel
| |||||||||||||||||||||||||||||||||||||||
| 83 | 8 | ▶ | if ( not( defined($type) ) or ( $type eq ( $link->type || '' ) ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not defined $type or $type eq ($link->type || "")
$link->type || ''
MC/DC50%1/2
not defined $type or $type eq ($link->type || "")
not defined $type
$type eq ($link->type || "")
MC/DC0%0/1
$link->type || ''
$link->type
Truth table66%2/3
not(A) or B
A= not defined $typeB= $type eq ($link->type || "")
Truth table50%1/2
A
A= $link->type
| |||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if ( not( defined($name) ) or ( $name eq ( $link->name || '' ) ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
not defined $name or $name eq ($link->name || "")
$link->name || ''
MC/DC0%0/2
not defined $name or $name eq ($link->name || "")
not defined $name
$name eq ($link->name || "")
MC/DC0%0/1
$link->name || ''
$link->name
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name eq ($link->name || "")
Truth table0%0/2
A
A= $link->name
| |||||||||||||||||||||||||||||||||||||||
| 85 | 1 | push( @matched_links, $link ); | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||
| 90 | 1 | return @matched_links; | |||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | method fetch_links (@search_items) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
fetch_links: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 97 | 1 | my @matched_objects; | |||||||||||||||||||||||||||||||||||||
| 98 | 1 | foreach my $link ( $self->find_links(@search_items) ) { | |||||||||||||||||||||||||||||||||||||
| 99 | 1 | push( @matched_objects, $link->GET() ); | |||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | 1 | return @matched_objects; | |||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ▶ | method _create_object ($hash, $type='Thing') { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
_create_object: called CC=7 SCAR=20.8
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | # if thing has Link content within it then it is a full object, otherwise it | ||||||||||||||||||||||||||||||||||||||
| 108 | # is just a stub | ||||||||||||||||||||||||||||||||||||||
| 109 | my $object = VMware::vCloudDirector::Object->new( | ||||||||||||||||||||||||||||||||||||||
| 110 | hash => { $type => $hash }, | ||||||||||||||||||||||||||||||||||||||
| 111 | api => $self->api, | ||||||||||||||||||||||||||||||||||||||
| 112 | 10 | ▶ | _partial_object => ( exists( $hash->{Link} ) ) ? 0 : 1, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||
| 114 | 10 | ▶ | $self->api->_debug( | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 115 | sprintf( | ||||||||||||||||||||||||||||||||||||||
| 116 | 'Object: [%s] instantiated %s for [%s]', | ||||||||||||||||||||||||||||||||||||||
| 117 | $self->type, ( $object->_partial_object ? 'a stub' : 'an object' ), | ||||||||||||||||||||||||||||||||||||||
| 118 | $object->type | ||||||||||||||||||||||||||||||||||||||
| 119 | ) | ||||||||||||||||||||||||||||||||||||||
| 120 | ) if ( $self->api->debug ); | ||||||||||||||||||||||||||||||||||||||
| 121 | 10 | return $object; | |||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | method build_sub_objects ($type) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
build_sub_objects: called CC=6 SCAR=18.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my @objects; | |||||||||||||||||||||||||||||||||||||
| 129 | 1 | my $container_type = noun($type)->plural; | |||||||||||||||||||||||||||||||||||||
| 130 | return | ||||||||||||||||||||||||||||||||||||||
| 131 | unless ( exists( $self->hash->{$container_type} ) | ||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | and is_plain_hashref( $self->hash->{$container_type} ) ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->hash->{$container_type} and is_plain_hashref($self->hash->{$container_type})
MC/DC0%0/2
exists $self->hash->{$container_type} and is_plain_hashref($self->hash->{$container_type})
exists $self->hash->{$container_type}
is_plain_hashref($self->hash->{$container_type})
Truth table33%1/3
A and B
A= exists $self->hash->{$container_type}B= is_plain_hashref($self->hash->{$container_type})
| |||||||||||||||||||||||||||||||||||||||
| 133 | 1 | foreach my $thing ( $self->_listify( $self->hash->{$container_type}{$type} ) ) { | |||||||||||||||||||||||||||||||||||||
| 134 | 7 | push( @objects, $self->_create_object( $thing, $type ) ); | |||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||
| 136 | 1 | return @objects; | |||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | method build_children_objects () { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
build_children_objects: called CC=6 SCAR=18.5
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 140 | 1 | my $hash = $self->hash; | |||||||||||||||||||||||||||||||||||||
| 141 | 1 | ▶ | return unless ( exists( $hash->{Children} ) and is_plain_hashref( $hash->{Children} ) ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $hash->{"Children"} and is_plain_hashref($hash->{"Children"})
MC/DC0%0/2
exists $hash->{"Children"} and is_plain_hashref($hash->{"Children"})
exists $hash->{"Children"}
is_plain_hashref($hash->{"Children"})
Truth table33%1/3
A and B
A= exists $hash->{"Children"}B= is_plain_hashref($hash->{"Children"})
| |||||||||||||||||||||||||||||||||||||||
| 142 | 1 | my @objects; | |||||||||||||||||||||||||||||||||||||
| 143 | 1 | foreach my $key ( keys %{ $hash->{Children} } ) { | |||||||||||||||||||||||||||||||||||||
| 144 | 1 | foreach my $thing ( $self->_listify( $self->hash->{Children}{$key} ) ) { | |||||||||||||||||||||||||||||||||||||
| 145 | 3 | push( @objects, $self->_create_object( $thing, $key ) ); | |||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||
| 148 | 1 | return @objects; | |||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | method DELETE () { return $self->api->GET( $self->href ); } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.1
Subroutine
DELETE: not called CC=2 SCAR=12.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | 4 | ▶ | method GET () { return $self->api->GET( $self->href ); } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.1
Subroutine
GET: not called CC=2 SCAR=12.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||
| 160 | 4 | ▶ | method POST ($xml_hash) { return $self->api->GET( $self->href, $xml_hash ); } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.4
Subroutine
POST: not called CC=3 SCAR=20.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | 4 | ▶ | method PUT ($xml_hash) { return $self->api->GET( $self->href, $xml_hash ); } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.4
Subroutine
PUT: not called CC=3 SCAR=20.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||
| 165 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | method _listify ($thing) { !defined $thing ? () : ( ( ref $thing eq 'ARRAY' ) ? @{$thing} : $thing ) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
_listify: called CC=5 SCAR=16.8
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | 4 | 1; | |||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||
| 174 | __END__ | ||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||
| 176 | =pod | ||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||
| 178 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||
| 182 | VMware::vCloudDirector::Object - Module to contain an object! | ||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||
| 186 | version 0.007 | ||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||
| 188 | =head2 Attributes | ||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||
| 190 | =head3 api | ||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | A weak link to the API object to be used. | ||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||
| 194 | =head3 content | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | The object content. This is in a separate container so that partial objects | ||||||||||||||||||||||||||||||||||||||
| 197 | passed can be inflated at a later stage without having to replace the object | ||||||||||||||||||||||||||||||||||||||
| 198 | itself. | ||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||
| 200 | =head3 hash | ||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||
| 202 | A reference to the hash returned from the vCloud XML. Forces object inflation. | ||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||
| 204 | =head3 links | ||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||
| 206 | An array references to the links contained in this object. Forces object | ||||||||||||||||||||||||||||||||||||||
| 207 | inflation. | ||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||
| 209 | =head3 id | ||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||
| 211 | The id attribute from the returned vCloud XML. Forces object inflation. | ||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||
| 213 | =head2 Methods | ||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||
| 215 | =head3 inflate | ||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||
| 217 | If this object is a partial object (ie taken from a link or partial chunk | ||||||||||||||||||||||||||||||||||||||
| 218 | within a containing object), then this forces a refetch of the content from | ||||||||||||||||||||||||||||||||||||||
| 219 | vCloud creating a fully populated object. | ||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||
| 221 | =head3 refetch | ||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||
| 223 | Forces a refetch of this object's content unconditionally. | ||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | =head3 find_links | ||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | Returns any links found that match the search criteria. The possible criteria | ||||||||||||||||||||||||||||||||||||||
| 228 | are:- | ||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||
| 232 | =item name | ||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||
| 234 | The name of the link | ||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||
| 236 | =item type | ||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | The type of the link (short type, not full MIME type) | ||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||
| 240 | =item rel | ||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||
| 242 | The rel of the link | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | =back | ||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||
| 246 | The return value is a list of link objects. | ||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | =head3 fetch_links | ||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||
| 250 | As per L</find_links> except that each link found is fetched and expanded up as | ||||||||||||||||||||||||||||||||||||||
| 251 | an object. | ||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | =head3 build_sub_objects | ||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||
| 255 | Given a type (specifically a key used within the current object hash), grabs | ||||||||||||||||||||||||||||||||||||||
| 256 | the descendants of that key and instantiates them as partial objects (they can | ||||||||||||||||||||||||||||||||||||||
| 257 | then be inflated into full objects). | ||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | Due to the structure of the XML there will always be two layers, the inner | ||||||||||||||||||||||||||||||||||||||
| 260 | named singular thing, and the outer named as the plural of thing. Hence this | ||||||||||||||||||||||||||||||||||||||
| 261 | does magic with the language inflection module. | ||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||
| 263 | =head3 DELETE | ||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||
| 265 | Make a delete request to the URL of this object. Returns Objects. Failure | ||||||||||||||||||||||||||||||||||||||
| 266 | will generate an exception. See L<VMware::vCloudDirector::API/DELETE>. | ||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | =head3 GET | ||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||
| 270 | Make a get request to the URL of this object. Returns Objects. Failure will | ||||||||||||||||||||||||||||||||||||||
| 271 | generate an exception. See L<VMware::vCloudDirector::API/GET>. | ||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||
| 273 | =head3 POST | ||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||
| 275 | Make a post request with the specified payload to the URL of this object. | ||||||||||||||||||||||||||||||||||||||
| 276 | Returns Objects. Failure will generate an exception. See | ||||||||||||||||||||||||||||||||||||||
| 277 | L<VMware::vCloudDirector::API/POST>. | ||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||
| 279 | =head3 PUT | ||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||
| 281 | Make a put request with the specified payload to the URL of this object. | ||||||||||||||||||||||||||||||||||||||
| 282 | Returns Objects. Failure will generate an exception. See | ||||||||||||||||||||||||||||||||||||||
| 283 | L<VMware::vCloudDirector::API/PUT>. | ||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||
| 285 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||
| 287 | Nigel Metheringham <nigelm@cpan.org> | ||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||
| 289 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | This software is copyright (c) 2017 by Nigel Metheringham. | ||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||
| 293 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||
| 294 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||||||||||||||||||||