| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Fastly::Version; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
28
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
135
|
|
|
4
|
4
|
|
|
4
|
|
21
|
use base qw(Net::Fastly::Model); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
3240
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub _get_path { |
|
49
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
50
|
0
|
|
|
|
|
|
my $service = shift; |
|
51
|
0
|
|
|
|
|
|
my $number = shift; |
|
52
|
0
|
|
|
|
|
|
return "/service/$service/version/$number"; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _post_path { |
|
56
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
57
|
0
|
|
|
|
|
|
my %opts = @_; |
|
58
|
0
|
|
|
|
|
|
return "/service/".$opts{service_id}."/version"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _put_path { |
|
62
|
0
|
|
|
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
|
|
|
|
|
|
|
sub service { |
|
77
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub settings { |
|
87
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub activate { |
|
97
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub deactivate { |
|
108
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub clone { |
|
119
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub generated_vcl { |
|
130
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
131
|
0
|
|
|
|
|
|
my $hash = $self->_fetcher->client->_get($self->_put_path($self)."/generated_vcl", @_); |
|
132
|
0
|
0
|
|
|
|
|
return undef unless defined $hash; |
|
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 |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Upload a raw VCL file to be used by the system. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
sub upload_vcl { |
|
147
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
return undef unless defined $hash; |
|
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
|
|
|
|
|
|
|
sub vcl { |
|
163
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub validate { |
|
175
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
176
|
0
|
|
|
|
|
|
my $hash = $self->_fetcher->client->_get($self->_put_path($self)."/validate"); |
|
177
|
0
|
|
|
|
|
|
return defined $hash; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |