| 1 | package VMware::vCloudDirector::Link; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Link within the vCloud | ||||||||||||||
| 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 MooseX::Types::URI qw(Uri); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 4 | ▶ | use Ref::Util qw(is_plain_hashref); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 4 | ▶ | use VMware::vCloudDirector::Error; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | # ------------------------------------------------------------------------ | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 4 | has object => ( | |||||||||||||
| 20 | is => 'ro', | ||||||||||||||
| 21 | isa => 'VMware::vCloudDirector::Object', | ||||||||||||||
| 22 | required => 1, | ||||||||||||||
| 23 | weak_ref => 1, | ||||||||||||||
| 24 | documentation => 'Parent object of link' | ||||||||||||||
| 25 | ); | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 4 | has mime_type => ( is => 'ro', isa => 'Str', predicate => 'has_mime_type' ); | |||||||||||||
| 28 | 4 | has href => ( is => 'ro', isa => Uri, required => 1, coerce => 1 ); | |||||||||||||
| 29 | 4 | has rel => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||
| 30 | 4 | has name => ( is => 'ro', isa => 'Str', predicate => 'has_name' ); | |||||||||||||
| 31 | 4 | has type => ( is => 'ro', isa => 'Str' ); | |||||||||||||
| 32 | |||||||||||||||
| 33 | # ------------------------------------------------------------------------ | ||||||||||||||
| 34 | around BUILDARGS => sub { | ||||||||||||||
| 35 | 10 | ▶ | my ( $orig, $class, $first, @rest ) = @_; | ||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.7
| |||||||||||||||
| 36 | |||||||||||||||
| 37 | 10 | ▶ | my $params = is_plain_hashref($first) ? $first : { $first, @rest }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | |||||||||||||||
| 39 | 10 | ▶ | if ( $params->{hash} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 10 | my $hash = delete $params->{hash}; | |||||||||||||
| 41 | 10 | ▶ | $params->{href} = $hash->{-href} if ( exists( $hash->{-href} ) ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 42 | 10 | ▶ | $params->{rel} = $hash->{-rel} if ( exists( $hash->{-rel} ) ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 10 | ▶ | $params->{name} = $hash->{-name} if ( exists( $hash->{-name} ) ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 10 | ▶ | if ( exists( $hash->{-type} ) ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | 10 | my $type = $hash->{-type}; | |||||||||||||
| 46 | 10 | $params->{mime_type} = $type; | |||||||||||||
| 47 | 10 | ▶ | $params->{type} = $1 if ( $type =~ m|^application/vnd\..*\.(\w+)\+xml$| ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | } | ||||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 10 | return $class->$orig($params); | |||||||||||||
| 52 | 4 | }; | |||||||||||||
| 53 | |||||||||||||||
| 54 | # ------------------------------------------------------------------------ | ||||||||||||||
| 55 | |||||||||||||||
| 56 | |||||||||||||||
| 57 | 4 | ▶ | method DELETE () { return $self->object->api->GET( $self->href ); } | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.1
Subroutine
DELETE: not called CC=2 SCAR=12.4
Branch: 1 branch
| |||||||||||||||
| 58 | |||||||||||||||
| 59 | |||||||||||||||
| 60 | 4 | ▶ | method GET () { return $self->object->api->GET( $self->href ); } | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
GET: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||
| 61 | |||||||||||||||
| 62 | |||||||||||||||
| 63 | 4 | ▶ | method POST ($xml_hash) { return $self->object->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
| |||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | 4 | ▶ | method PUT ($xml_hash) { return $self->object->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
| |||||||||||||||
| 67 | |||||||||||||||
| 68 | # ------------------------------------------------------------------------ | ||||||||||||||
| 69 | |||||||||||||||
| 70 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 71 | |||||||||||||||
| 72 | 4 | 1; | |||||||||||||
| 73 | |||||||||||||||
| 74 | __END__ | ||||||||||||||
| 75 | |||||||||||||||
| 76 | =pod | ||||||||||||||
| 77 | |||||||||||||||
| 78 | =encoding UTF-8 | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head1 NAME | ||||||||||||||
| 81 | |||||||||||||||
| 82 | VMware::vCloudDirector::Link - Link within the vCloud | ||||||||||||||
| 83 | |||||||||||||||
| 84 | =head1 VERSION | ||||||||||||||
| 85 | |||||||||||||||
| 86 | version 0.007 | ||||||||||||||
| 87 | |||||||||||||||
| 88 | =head3 DELETE | ||||||||||||||
| 89 | |||||||||||||||
| 90 | Make a delete request to the URL in this link. Returns Objects. Failure will | ||||||||||||||
| 91 | generate an exception. See L<VMware::vCloudDirector::API/DELETE>. | ||||||||||||||
| 92 | |||||||||||||||
| 93 | =head3 GET | ||||||||||||||
| 94 | |||||||||||||||
| 95 | Make a get request to the URL in this link. Returns Objects. Failure will | ||||||||||||||
| 96 | generate an exception. See L<VMware::vCloudDirector::API/GET>. | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =head3 POST | ||||||||||||||
| 99 | |||||||||||||||
| 100 | Make a post request with the specified payload to the URL in this link. Returns | ||||||||||||||
| 101 | Objects. Failure will generate an exception. See | ||||||||||||||
| 102 | L<VMware::vCloudDirector::API/POST>. | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =head3 PUT | ||||||||||||||
| 105 | |||||||||||||||
| 106 | Make a put request with the specified payload to the URL in this link. Returns | ||||||||||||||
| 107 | Objects. Failure will generate an exception. See | ||||||||||||||
| 108 | L<VMware::vCloudDirector::API/PUT>. | ||||||||||||||
| 109 | |||||||||||||||
| 110 | =head1 AUTHOR | ||||||||||||||
| 111 | |||||||||||||||
| 112 | Nigel Metheringham <nigelm@cpan.org> | ||||||||||||||
| 113 | |||||||||||||||
| 114 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 115 | |||||||||||||||
| 116 | This software is copyright (c) 2017 by Nigel Metheringham. | ||||||||||||||
| 117 | |||||||||||||||
| 118 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||
| 119 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||
| 120 | |||||||||||||||
| 121 | =cut | ||||||||||||||