| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Fastly::Service; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
28
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
146
|
|
|
4
|
4
|
|
|
4
|
|
21
|
use base qw(Net::Fastly::Model); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
3008
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Net::Fastly::Service->mk_accessors(qw(id customer_id name comment)); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::Fastly::Service - a representation of a Fastly service |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 id |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
The id of the service |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 customer |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The id of the customer this belongs to |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 name |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The name of this service |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 comment |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
a free form comment field |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 stats [type] |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Get an hash ref of stats from different data centers. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Type can be one of |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item minutely |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item hourly |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item daily |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item all (default) |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub stats { |
|
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
58
|
0
|
|
0
|
|
|
|
my $type = shift || "all"; |
|
59
|
0
|
|
|
|
|
|
my %opts = @_; |
|
60
|
0
|
0
|
|
|
|
|
die "Unknown stats type $type" unless grep { $_ eq $type } qw(minutely hourly daily all); |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->_fetcher->client->_get($self->_get_path($self->id)."/stats/".$type, %opts); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 invoice [ ] |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Return a Net::Fastly::Invoice objects representing the invoice for this service |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If a year and month are passed in returns the invoice for that whole month. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Otherwise it returns the invoice for the current month so far. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
sub invoice { |
|
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
75
|
0
|
|
|
|
|
|
my $year = shift; |
|
76
|
0
|
|
|
|
|
|
my $month = shift; |
|
77
|
0
|
|
|
|
|
|
my %opts = ( service_id => $self->id ); |
|
78
|
0
|
0
|
0
|
|
|
|
if ($year && $month) { |
|
79
|
0
|
|
|
|
|
|
$opts{year} = $year; |
|
80
|
0
|
|
|
|
|
|
$opts{month} = $month; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
0
|
|
|
|
|
|
return $self->_fetcher->_get('Net::Fastly::Invoice', %opts); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 purge_all |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Purge all assets from this service. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
sub purge_all { |
|
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
93
|
0
|
|
|
|
|
|
return $self->_fetcher->client->_post($self->_get_path($self->id)."/purge_all"); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 purge_by_key |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Purge anything with the specific key from the given service. Requires an API key. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can optionally pass in a true value to enable "soft" purging e.g |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$service->purge_by_key($key, 1); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See L |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
|
107
|
|
|
|
|
|
|
sub purge_by_key { |
|
108
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
109
|
0
|
|
|
|
|
|
my $key = shift; |
|
110
|
0
|
|
|
|
|
|
my $soft = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
unless ($self->_fetcher->client->key_authed) { |
|
113
|
0
|
|
|
|
|
|
die ("Purging by key requires API key authentication."); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $self->_fetcher->client->_post($self->_get_path($self->id)."/purge/$key", headers => { 'Fastly-Soft-Purge' => $soft }); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 versions |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Get a sorted array of all the versions that this service has had. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
sub versions { |
|
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
126
|
0
|
|
|
|
|
|
my $fetcher = $self->_fetcher; |
|
127
|
0
|
0
|
|
|
|
|
my @versions = map { Net::Fastly::Version->new($fetcher, %$_) } @{$self->{versions}||{}}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return sort { $a->number <=> $b->number } @versions; |
|
|
0
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 version |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Get the current version of this service. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
sub version { |
|
137
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
138
|
0
|
|
|
|
|
|
my @list = $self->versions; |
|
139
|
0
|
|
|
|
|
|
return $list[-1]; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 details |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
A deep hash of nested details |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
sub details { |
|
148
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
149
|
0
|
|
|
|
|
|
$self->_fetcher->client->_get($self->_get_path($self->id)."/details", @_); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
package Net::Fastly; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub search_services { |
|
156
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
157
|
0
|
|
|
|
|
|
my %opts = @_; |
|
158
|
0
|
|
|
|
|
|
my $class = "Net::Fastly::Service"; |
|
159
|
0
|
|
|
|
|
|
my $hash = $self->client->_get($class->_post_path."/search", %opts); |
|
160
|
0
|
0
|
|
|
|
|
return undef unless $hash; |
|
161
|
0
|
|
|
|
|
|
return $class->new($self, %$hash); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
1; |