Fastly/Version.pm

filter: Statementstmt 16.3% 8 / 49 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 14.2% 2 / 14 Podpod 100% 9 / 9 totaltotal 25.0% 19 / 76 CC 3 SCAR 10.6
CC
3
Cov
15%
generated_vcl
6.0
upload_vcl
6.0
_get_path
2.0
CRAP 2.9
« Fastly/BelongsToServiceAndVersion.pm ↑ Summary Fastly/Settings.pm »
1 package Net::Fastly::Version;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use base qw(Net::Fastly::Model);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 Net::Fastly::Version->mk_accessors(qw(service_id number name active locked staging testing deployed comment created_at updated_at));
7  
8 =head1 NAME
9  
10 Net::Fastly::Version - a representation of a version of a service
11  
12 =head1 ACCESSORS
13  
14 =head2 service_id
15  
16 The id of the service this belongs to.
17  
18 =head2 name
19  
20 The name of this version.
21  
22 =head2 active
23  
24 Whether this version is active or not.
25  
26 =head2 locked
27  
28 Whether this version is locked or not.
29  
30 =head2 staging
31  
32 Whether this version is in staging or not.
33  
34 =head2 testing
35  
36 Whether this version is in testing or not.
37  
38 =head2 deployed
39  
40 Whether this version is deployed or not.
41  
42 =head2 comment
43  
44 a free form comment field
45  
46 =cut
47  
48 0 ▶sub _get_path {
Subroutine _get_path: not called CC=1 SCAR=6.9
49 0 my $class = shift;
50 0 my $service = shift;
51 0 my $number = shift;
52 0 return "/service/$service/version/$number";
53 }
54  
55 0 ▶sub _post_path {
Subroutine _post_path: not called CC=1 SCAR=6.9
56 0 my $class = shift;
57 0 my %opts = @_;
58 0 return "/service/".$opts{service_id}."/version";
59 }
60  
61 0 ▶sub _put_path {
Subroutine _put_path: not called CC=1 SCAR=6.9
62 0 my $class = shift;
63 0 my $obj = shift;
64 0 return $class->_get_path($obj->service_id, $obj->number);
65 }
66
67 =head1 METHODS
68  
69 =cut
70  
71 =head2 service
72  
73 Get the service object for this version
74  
75 =cut
76 0 ▶sub service {
Subroutine service: not called CC=1 SCAR=6.9
Pod documented
77 0 my $self = shift;
78 0 return $self->_fetcher->_get("Net::Fastly::Service", $self->service_id);
79 }
80  
81 =head2 settings
82  
83 Get the settings object for this version
84  
85 =cut
86 0 ▶sub settings {
Subroutine settings: not called CC=1 SCAR=6.9
Pod documented
87 0 my $self = shift;
88 0 return $self->_fetcher->get_settings($self->service_id, $self->number);
89 }
90  
91 =head2 activate
92  
93 Activate this version. This will cause it to be deployed.
94  
95 =cut
96 0 ▶sub activate {
Subroutine activate: not called CC=1 SCAR=6.9
Pod documented
97 0 my $self = shift;
98 0 my $hash = $self->_fetcher->client->_put($self->_put_path($self)."/activate");
99 0 return defined $hash;
100 }
101  
102 =head2 deactivate
103  
104 Deactivate this version.
105  
106 =cut
107 0 ▶sub deactivate {
Subroutine deactivate: not called CC=1 SCAR=6.9
Pod documented
108 0 my $self = shift;
109 0 my $hash = $self->_fetcher->client->_put($self->_put_path($self)."/deactivate");
110 0 return defined $hash;
111 }
112  
113 =head2 clone
114  
115 Clone this version - creates a new version which can then be modified and deployed.
116  
117 =cut
118 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
119 0 my $self = shift;
120 0 my $hash = $self->_fetcher->client->_put($self->_put_path($self)."/clone");
121 0 return Net::Fastly::Version->new($self->_fetcher, %$hash);
122 }
123  
124 =head2 generated_vcl
125  
126 Get the VCL object representing the VCL file generated by the system.
127  
128 =cut
129 0 ▶sub generated_vcl {
Subroutine generated_vcl: not called CC=2 SCAR=17.9
Pod documented
130 0 my $self = shift;
131 0 my $hash = $self->_fetcher->client->_get($self->_put_path($self)."/generated_vcl", @_);
132 0 ▶ return undef unless defined $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash 0 0 0
133 return Net::Fastly::VCL->new($self->_fetcher,
134 content => $hash->{content},
135 name => $hash->{md5},
136 version => $hash->{version},
137 service_id => $hash->{service_id},
138 0 );
139 }
140  
141 =head2 upload_vcl <name> <content>
142  
143 Upload a raw VCL file to be used by the system.
144  
145 =cut
146 0 ▶sub upload_vcl {
Subroutine upload_vcl: not called CC=2 SCAR=17.9
Pod documented
147 0 my $self = shift;
148 0 my $name = shift;
149 0 my $content = shift;
150 0 my %params = @_;
151 0 my $hash = $self->_fetcher->client->_post($self->_put_path($self)."/vcl", name => $name, content => $content, %params);
152 0 ▶ return undef unless defined $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash 0 0 0
153 0 return Net::Fastly::VCL->new($self->_fetcher, %$hash);
154 }
155  
156 =head2 vcl
157  
158 The uploaded vcl for this version
159  
160 =cut
161  
162 0 ▶sub vcl {
Subroutine vcl: not called CC=1 SCAR=6.9
Pod documented
163 0 my $self = shift;
164 0 my $name = shift;
165 0 my $vcl = $self->_fetcher->get_vcl($self->service_id, $self->number, $name, @_);
166 0 return $vcl;
167 }
168  
169 =head2 validate
170  
171 Validate the current setup.
172  
173 =cut
174 0 ▶sub validate {
Subroutine validate: not called CC=1 SCAR=6.9
Pod documented
175 0 my $self = shift;
176 0 my $hash = $self->_fetcher->client->_get($self->_put_path($self)."/validate");
177 0 return defined $hash;
178 }
179  
180 5 1;
« Fastly/BelongsToServiceAndVersion.pm ↑ Summary Fastly/Settings.pm »