Fastly/HistoricalApi.pm untested

filter: Statementstmt 0.0% 0 / 319 Branchbran 0.0% 0 / 118 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 19 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 475 CC 60 SCAR 43.2
CC
60
Cov
0%
get_hist_stats_service_field
156.0
get_hist_stats_field
110.0
get_hist_stats_service
110.0
CRAP 75.5
1 =begin comment
2  
3 Fastly API
4  
5 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
6  
7 The version of the API Spec document: 1.0.0
8 Contact: oss@fastly.com
9  
10 =end comment
11  
12 =cut
13  
14 #
15 # NOTE: This class is auto generated.
16 # Do not edit the class manually.
17 #
18 package WebService::Fastly::HistoricalApi;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use Exporter;
25 use Carp qw( croak );
26 use Log::Any qw($log);
27  
28 use WebService::Fastly::ApiClient;
29  
30 use base "Class::Data::Inheritable";
31  
32 __PACKAGE__->mk_classdata('method_documentation' => {});
33  
34 sub new {
35 my $class = shift;
36 my $api_client;
37  
38 if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) {
39 $api_client = $_[0];
40 } else {
41 $api_client = WebService::Fastly::ApiClient->new(@_);
42 }
43  
44 bless { api_client => $api_client }, $class;
45  
46 }
47  
48  
49 #
50 # get_hist_stats
51 #
52 # Get historical stats
53 #
54 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
55 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
56 # @param string $by Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (optional, default to 'day')
57 # @param string $region Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. (optional)
58 # @param string $datacenter Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). (optional)
59 # @param string $services Limit the query to only the specified, comma-separated list of services. (optional)
60 {
61 my $params = {
62 'from' => {
63 data_type => 'string',
64 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
65 required => '0',
66 },
67 'to' => {
68 data_type => 'string',
69 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
70 required => '0',
71 },
72 'by' => {
73 data_type => 'string',
74 description => 'Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. ',
75 required => '0',
76 },
77 'region' => {
78 data_type => 'string',
79 description => 'Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. ',
80 required => '0',
81 },
82 'datacenter' => {
83 data_type => 'string',
84 description => 'Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). ',
85 required => '0',
86 },
87 'services' => {
88 data_type => 'string',
89 description => 'Limit the query to only the specified, comma-separated list of services. ',
90 required => '0',
91 },
92 };
93 __PACKAGE__->method_documentation->{ 'get_hist_stats' } = {
94 summary => 'Get historical stats',
95 params => $params,
96 returns => 'HistoricalStatsByServiceResponse',
97 };
98 }
99 # @return HistoricalStatsByServiceResponse
100 #
101 sub get_hist_stats {
102 my ($self, %args) = @_;
103  
104 # parse inputs
105 my $_resource_path = '/stats';
106  
107 my $_method = 'GET';
108 my $query_params = {};
109 my $header_params = {};
110 my $form_params = {};
111  
112 # 'Accept' and 'Content-Type' header
113 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
114 if ($_header_accept) {
115 $header_params->{'Accept'} = $_header_accept;
116 }
117 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
118  
119 # query params
120 if ( exists $args{'from'}) {
121 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
122 }
123  
124 # query params
125 if ( exists $args{'to'}) {
126 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
127 }
128  
129 # query params
130 if ( exists $args{'by'}) {
131 $query_params->{'by'} = $self->{api_client}->to_query_value($args{'by'});
132 }
133  
134 # query params
135 if ( exists $args{'region'}) {
136 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
137 }
138  
139 # query params
140 if ( exists $args{'datacenter'}) {
141 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
142 }
143  
144 # query params
145 if ( exists $args{'services'}) {
146 $query_params->{'services'} = $self->{api_client}->to_query_value($args{'services'});
147 }
148  
149 my $_body_data;
150 # authentication setting, if any
151 my $auth_settings = [qw(token )];
152  
153 # make the API Call
154 my $response = $self->{api_client}->call_api($_resource_path, $_method,
155 $query_params, $form_params,
156 $header_params, $_body_data, $auth_settings);
157 if (!$response) {
158 return;
159 }
160 my $_response_object = $self->{api_client}->deserialize('HistoricalStatsByServiceResponse', $response);
161 return $_response_object;
162 }
163  
164 #
165 # get_hist_stats_aggregated
166 #
167 # Get aggregated historical stats
168 #
169 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
170 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
171 # @param string $by Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (optional, default to 'day')
172 # @param string $region Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. (optional)
173 {
174 my $params = {
175 'from' => {
176 data_type => 'string',
177 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
178 required => '0',
179 },
180 'to' => {
181 data_type => 'string',
182 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
183 required => '0',
184 },
185 'by' => {
186 data_type => 'string',
187 description => 'Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. ',
188 required => '0',
189 },
190 'region' => {
191 data_type => 'string',
192 description => 'Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. ',
193 required => '0',
194 },
195 };
196 __PACKAGE__->method_documentation->{ 'get_hist_stats_aggregated' } = {
197 summary => 'Get aggregated historical stats',
198 params => $params,
199 returns => 'HistoricalStatsAggregatedResponse',
200 };
201 }
202 # @return HistoricalStatsAggregatedResponse
203 #
204 sub get_hist_stats_aggregated {
205 my ($self, %args) = @_;
206  
207 # parse inputs
208 my $_resource_path = '/stats/aggregate';
209  
210 my $_method = 'GET';
211 my $query_params = {};
212 my $header_params = {};
213 my $form_params = {};
214  
215 # 'Accept' and 'Content-Type' header
216 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
217 if ($_header_accept) {
218 $header_params->{'Accept'} = $_header_accept;
219 }
220 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
221  
222 # query params
223 if ( exists $args{'from'}) {
224 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
225 }
226  
227 # query params
228 if ( exists $args{'to'}) {
229 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
230 }
231  
232 # query params
233 if ( exists $args{'by'}) {
234 $query_params->{'by'} = $self->{api_client}->to_query_value($args{'by'});
235 }
236  
237 # query params
238 if ( exists $args{'region'}) {
239 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
240 }
241  
242 my $_body_data;
243 # authentication setting, if any
244 my $auth_settings = [qw(token )];
245  
246 # make the API Call
247 my $response = $self->{api_client}->call_api($_resource_path, $_method,
248 $query_params, $form_params,
249 $header_params, $_body_data, $auth_settings);
250 if (!$response) {
251 return;
252 }
253 my $_response_object = $self->{api_client}->deserialize('HistoricalStatsAggregatedResponse', $response);
254 return $_response_object;
255 }
256  
257 #
258 # get_hist_stats_field
259 #
260 # Get historical stats for a single field
261 #
262 # @param string $field Name of the stats field. (required)
263 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
264 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
265 # @param string $by Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (optional, default to 'day')
266 # @param string $region Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. (optional)
267 # @param string $datacenter Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). (optional)
268 {
269 my $params = {
270 'field' => {
271 data_type => 'string',
272 description => 'Name of the stats field.',
273 required => '1',
274 },
275 'from' => {
276 data_type => 'string',
277 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
278 required => '0',
279 },
280 'to' => {
281 data_type => 'string',
282 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
283 required => '0',
284 },
285 'by' => {
286 data_type => 'string',
287 description => 'Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. ',
288 required => '0',
289 },
290 'region' => {
291 data_type => 'string',
292 description => 'Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. ',
293 required => '0',
294 },
295 'datacenter' => {
296 data_type => 'string',
297 description => 'Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). ',
298 required => '0',
299 },
300 };
301 __PACKAGE__->method_documentation->{ 'get_hist_stats_field' } = {
302 summary => 'Get historical stats for a single field',
303 params => $params,
304 returns => 'HistoricalStatsByServiceResponse',
305 };
306 }
307 # @return HistoricalStatsByServiceResponse
308 #
309 sub get_hist_stats_field {
310 my ($self, %args) = @_;
311  
312 # verify the required parameter 'field' is set
313 unless (exists $args{'field'}) {
314 croak("Missing the required parameter 'field' when calling get_hist_stats_field");
315 }
316  
317 # parse inputs
318 my $_resource_path = '/stats/field/{field}';
319  
320 my $_method = 'GET';
321 my $query_params = {};
322 my $header_params = {};
323 my $form_params = {};
324  
325 # 'Accept' and 'Content-Type' header
326 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
327 if ($_header_accept) {
328 $header_params->{'Accept'} = $_header_accept;
329 }
330 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
331  
332 # query params
333 if ( exists $args{'from'}) {
334 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
335 }
336  
337 # query params
338 if ( exists $args{'to'}) {
339 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
340 }
341  
342 # query params
343 if ( exists $args{'by'}) {
344 $query_params->{'by'} = $self->{api_client}->to_query_value($args{'by'});
345 }
346  
347 # query params
348 if ( exists $args{'region'}) {
349 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
350 }
351  
352 # query params
353 if ( exists $args{'datacenter'}) {
354 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
355 }
356  
357 # path params
358 if ( exists $args{'field'}) {
359 my $_base_variable = "{" . "field" . "}";
360 my $_base_value = $self->{api_client}->to_path_value($args{'field'});
361 $_resource_path =~ s/$_base_variable/$_base_value/g;
362 }
363  
364 my $_body_data;
365 # authentication setting, if any
366 my $auth_settings = [qw(token )];
367  
368 # make the API Call
369 my $response = $self->{api_client}->call_api($_resource_path, $_method,
370 $query_params, $form_params,
371 $header_params, $_body_data, $auth_settings);
372 if (!$response) {
373 return;
374 }
375 my $_response_object = $self->{api_client}->deserialize('HistoricalStatsByServiceResponse', $response);
376 return $_response_object;
377 }
378  
379 #
380 # get_hist_stats_service
381 #
382 # Get historical stats for a single service
383 #
384 # @param string $service_id Alphanumeric string identifying the service. (required)
385 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
386 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
387 # @param string $by Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (optional, default to 'day')
388 # @param string $region Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. (optional)
389 # @param string $datacenter Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). (optional)
390 {
391 my $params = {
392 'service_id' => {
393 data_type => 'string',
394 description => 'Alphanumeric string identifying the service.',
395 required => '1',
396 },
397 'from' => {
398 data_type => 'string',
399 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
400 required => '0',
401 },
402 'to' => {
403 data_type => 'string',
404 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
405 required => '0',
406 },
407 'by' => {
408 data_type => 'string',
409 description => 'Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. ',
410 required => '0',
411 },
412 'region' => {
413 data_type => 'string',
414 description => 'Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. ',
415 required => '0',
416 },
417 'datacenter' => {
418 data_type => 'string',
419 description => 'Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). ',
420 required => '0',
421 },
422 };
423 __PACKAGE__->method_documentation->{ 'get_hist_stats_service' } = {
424 summary => 'Get historical stats for a single service',
425 params => $params,
426 returns => 'HistoricalStatsAggregatedResponse',
427 };
428 }
429 # @return HistoricalStatsAggregatedResponse
430 #
431 sub get_hist_stats_service {
432 my ($self, %args) = @_;
433  
434 # verify the required parameter 'service_id' is set
435 unless (exists $args{'service_id'}) {
436 croak("Missing the required parameter 'service_id' when calling get_hist_stats_service");
437 }
438  
439 # parse inputs
440 my $_resource_path = '/stats/service/{service_id}';
441  
442 my $_method = 'GET';
443 my $query_params = {};
444 my $header_params = {};
445 my $form_params = {};
446  
447 # 'Accept' and 'Content-Type' header
448 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
449 if ($_header_accept) {
450 $header_params->{'Accept'} = $_header_accept;
451 }
452 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
453  
454 # query params
455 if ( exists $args{'from'}) {
456 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
457 }
458  
459 # query params
460 if ( exists $args{'to'}) {
461 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
462 }
463  
464 # query params
465 if ( exists $args{'by'}) {
466 $query_params->{'by'} = $self->{api_client}->to_query_value($args{'by'});
467 }
468  
469 # query params
470 if ( exists $args{'region'}) {
471 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
472 }
473  
474 # query params
475 if ( exists $args{'datacenter'}) {
476 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
477 }
478  
479 # path params
480 if ( exists $args{'service_id'}) {
481 my $_base_variable = "{" . "service_id" . "}";
482 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
483 $_resource_path =~ s/$_base_variable/$_base_value/g;
484 }
485  
486 my $_body_data;
487 # authentication setting, if any
488 my $auth_settings = [qw(token )];
489  
490 # make the API Call
491 my $response = $self->{api_client}->call_api($_resource_path, $_method,
492 $query_params, $form_params,
493 $header_params, $_body_data, $auth_settings);
494 if (!$response) {
495 return;
496 }
497 my $_response_object = $self->{api_client}->deserialize('HistoricalStatsAggregatedResponse', $response);
498 return $_response_object;
499 }
500  
501 #
502 # get_hist_stats_service_field
503 #
504 # Get historical stats for a single service/field combination
505 #
506 # @param string $service_id Alphanumeric string identifying the service. (required)
507 # @param string $field Name of the stats field. (required)
508 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
509 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
510 # @param string $by Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. (optional, default to 'day')
511 # @param string $region Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. (optional)
512 # @param string $datacenter Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). (optional)
513 {
514 my $params = {
515 'service_id' => {
516 data_type => 'string',
517 description => 'Alphanumeric string identifying the service.',
518 required => '1',
519 },
520 'field' => {
521 data_type => 'string',
522 description => 'Name of the stats field.',
523 required => '1',
524 },
525 'from' => {
526 data_type => 'string',
527 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
528 required => '0',
529 },
530 'to' => {
531 data_type => 'string',
532 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
533 required => '0',
534 },
535 'by' => {
536 data_type => 'string',
537 description => 'Duration of sample windows. One of: * `hour` - Group data by hour. * `minute` - Group data by minute. * `day` - Group data by day. ',
538 required => '0',
539 },
540 'region' => {
541 data_type => 'string',
542 description => 'Limit query to a specific geographic region. One of: * `usa` - North America. * `europe` - Europe. * `anzac` - Australia and New Zealand. * `asia` - Asia. * `asia_india` - India. * `asia_southkorea` - South Korea. * `africa_std` - Africa. * `mexico` - Mexico. * `southamerica_std` - South America. * `saudi_arabia` - Saudi Arabia. ',
543 required => '0',
544 },
545 'datacenter' => {
546 data_type => 'string',
547 description => 'Limit query to one or more Fastly POPs. For multiple POPs use a comma-seperated list of POPs. These must be all uppercase and be valid codes. A full list of POPs can be obtained from the [POPs endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/). ',
548 required => '0',
549 },
550 };
551 __PACKAGE__->method_documentation->{ 'get_hist_stats_service_field' } = {
552 summary => 'Get historical stats for a single service/field combination',
553 params => $params,
554 returns => 'HistoricalStatsAggregatedResponse',
555 };
556 }
557 # @return HistoricalStatsAggregatedResponse
558 #
559 sub get_hist_stats_service_field {
560 my ($self, %args) = @_;
561  
562 # verify the required parameter 'service_id' is set
563 unless (exists $args{'service_id'}) {
564 croak("Missing the required parameter 'service_id' when calling get_hist_stats_service_field");
565 }
566  
567 # verify the required parameter 'field' is set
568 unless (exists $args{'field'}) {
569 croak("Missing the required parameter 'field' when calling get_hist_stats_service_field");
570 }
571  
572 # parse inputs
573 my $_resource_path = '/stats/service/{service_id}/field/{field}';
574  
575 my $_method = 'GET';
576 my $query_params = {};
577 my $header_params = {};
578 my $form_params = {};
579  
580 # 'Accept' and 'Content-Type' header
581 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
582 if ($_header_accept) {
583 $header_params->{'Accept'} = $_header_accept;
584 }
585 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
586  
587 # query params
588 if ( exists $args{'from'}) {
589 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
590 }
591  
592 # query params
593 if ( exists $args{'to'}) {
594 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
595 }
596  
597 # query params
598 if ( exists $args{'by'}) {
599 $query_params->{'by'} = $self->{api_client}->to_query_value($args{'by'});
600 }
601  
602 # query params
603 if ( exists $args{'region'}) {
604 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
605 }
606  
607 # query params
608 if ( exists $args{'datacenter'}) {
609 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
610 }
611  
612 # path params
613 if ( exists $args{'service_id'}) {
614 my $_base_variable = "{" . "service_id" . "}";
615 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
616 $_resource_path =~ s/$_base_variable/$_base_value/g;
617 }
618  
619 # path params
620 if ( exists $args{'field'}) {
621 my $_base_variable = "{" . "field" . "}";
622 my $_base_value = $self->{api_client}->to_path_value($args{'field'});
623 $_resource_path =~ s/$_base_variable/$_base_value/g;
624 }
625  
626 my $_body_data;
627 # authentication setting, if any
628 my $auth_settings = [qw(token )];
629  
630 # make the API Call
631 my $response = $self->{api_client}->call_api($_resource_path, $_method,
632 $query_params, $form_params,
633 $header_params, $_body_data, $auth_settings);
634 if (!$response) {
635 return;
636 }
637 my $_response_object = $self->{api_client}->deserialize('HistoricalStatsAggregatedResponse', $response);
638 return $_response_object;
639 }
640  
641 #
642 # get_regions
643 #
644 # Get region codes
645 #
646 {
647 my $params = {
648 };
649 __PACKAGE__->method_documentation->{ 'get_regions' } = {
650 summary => 'Get region codes',
651 params => $params,
652 returns => 'HistoricalRegionsResponse',
653 };
654 }
655 # @return HistoricalRegionsResponse
656 #
657 sub get_regions {
658 my ($self, %args) = @_;
659  
660 # parse inputs
661 my $_resource_path = '/stats/regions';
662  
663 my $_method = 'GET';
664 my $query_params = {};
665 my $header_params = {};
666 my $form_params = {};
667  
668 # 'Accept' and 'Content-Type' header
669 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
670 if ($_header_accept) {
671 $header_params->{'Accept'} = $_header_accept;
672 }
673 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
674  
675 my $_body_data;
676 # authentication setting, if any
677 my $auth_settings = [qw(token )];
678  
679 # make the API Call
680 my $response = $self->{api_client}->call_api($_resource_path, $_method,
681 $query_params, $form_params,
682 $header_params, $_body_data, $auth_settings);
683 if (!$response) {
684 return;
685 }
686 my $_response_object = $self->{api_client}->deserialize('HistoricalRegionsResponse', $response);
687 return $_response_object;
688 }
689  
690 #
691 # get_usage
692 #
693 # Get usage statistics
694 #
695 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
696 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
697 {
698 my $params = {
699 'from' => {
700 data_type => 'string',
701 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
702 required => '0',
703 },
704 'to' => {
705 data_type => 'string',
706 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
707 required => '0',
708 },
709 };
710 __PACKAGE__->method_documentation->{ 'get_usage' } = {
711 summary => 'Get usage statistics',
712 params => $params,
713 returns => 'HistoricalUsageAggregatedResponse',
714 };
715 }
716 # @return HistoricalUsageAggregatedResponse
717 #
718 sub get_usage {
719 my ($self, %args) = @_;
720  
721 # parse inputs
722 my $_resource_path = '/stats/usage';
723  
724 my $_method = 'GET';
725 my $query_params = {};
726 my $header_params = {};
727 my $form_params = {};
728  
729 # 'Accept' and 'Content-Type' header
730 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
731 if ($_header_accept) {
732 $header_params->{'Accept'} = $_header_accept;
733 }
734 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
735  
736 # query params
737 if ( exists $args{'from'}) {
738 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
739 }
740  
741 # query params
742 if ( exists $args{'to'}) {
743 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
744 }
745  
746 my $_body_data;
747 # authentication setting, if any
748 my $auth_settings = [qw(token )];
749  
750 # make the API Call
751 my $response = $self->{api_client}->call_api($_resource_path, $_method,
752 $query_params, $form_params,
753 $header_params, $_body_data, $auth_settings);
754 if (!$response) {
755 return;
756 }
757 my $_response_object = $self->{api_client}->deserialize('HistoricalUsageAggregatedResponse', $response);
758 return $_response_object;
759 }
760  
761 #
762 # get_usage_month
763 #
764 # Get month-to-date usage statistics
765 #
766 # @param string $year 4-digit year. (optional)
767 # @param string $month 2-digit month. (optional)
768 # @param boolean $billable_units If `true`, return results as billable units. (optional)
769 {
770 my $params = {
771 'year' => {
772 data_type => 'string',
773 description => '4-digit year.',
774 required => '0',
775 },
776 'month' => {
777 data_type => 'string',
778 description => '2-digit month.',
779 required => '0',
780 },
781 'billable_units' => {
782 data_type => 'boolean',
783 description => 'If `true`, return results as billable units.',
784 required => '0',
785 },
786 };
787 __PACKAGE__->method_documentation->{ 'get_usage_month' } = {
788 summary => 'Get month-to-date usage statistics',
789 params => $params,
790 returns => 'HistoricalUsageMonthResponse',
791 };
792 }
793 # @return HistoricalUsageMonthResponse
794 #
795 sub get_usage_month {
796 my ($self, %args) = @_;
797  
798 # parse inputs
799 my $_resource_path = '/stats/usage_by_month';
800  
801 my $_method = 'GET';
802 my $query_params = {};
803 my $header_params = {};
804 my $form_params = {};
805  
806 # 'Accept' and 'Content-Type' header
807 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
808 if ($_header_accept) {
809 $header_params->{'Accept'} = $_header_accept;
810 }
811 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
812  
813 # query params
814 if ( exists $args{'year'}) {
815 $query_params->{'year'} = $self->{api_client}->to_query_value($args{'year'});
816 }
817  
818 # query params
819 if ( exists $args{'month'}) {
820 $query_params->{'month'} = $self->{api_client}->to_query_value($args{'month'});
821 }
822  
823 # query params
824 if ( exists $args{'billable_units'}) {
825 $query_params->{'billable_units'} = $self->{api_client}->to_query_value($args{'billable_units'});
826 }
827  
828 my $_body_data;
829 # authentication setting, if any
830 my $auth_settings = [qw(token )];
831  
832 # make the API Call
833 my $response = $self->{api_client}->call_api($_resource_path, $_method,
834 $query_params, $form_params,
835 $header_params, $_body_data, $auth_settings);
836 if (!$response) {
837 return;
838 }
839 my $_response_object = $self->{api_client}->deserialize('HistoricalUsageMonthResponse', $response);
840 return $_response_object;
841 }
842  
843 #
844 # get_usage_service
845 #
846 # Get usage statistics per service
847 #
848 # @param string $from Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. (optional)
849 # @param string $to Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. (optional, default to 'now')
850 {
851 my $params = {
852 'from' => {
853 data_type => 'string',
854 description => 'Timestamp that defines the start of the window for which to fetch statistics, including the timestamp itself. Accepts Unix timestamps, or any form of input parsable by the [Chronic Ruby library](https://github.com/mojombo/chronic), such as 'yesterday', or 'two weeks ago'. Default varies based on the value of `by`. ',
855 required => '0',
856 },
857 'to' => {
858 data_type => 'string',
859 description => 'Timestamp that defines the end of the window for which to fetch statistics. Accepts the same formats as `from`. ',
860 required => '0',
861 },
862 };
863 __PACKAGE__->method_documentation->{ 'get_usage_service' } = {
864 summary => 'Get usage statistics per service',
865 params => $params,
866 returns => 'HistoricalUsageServiceResponse',
867 };
868 }
869 # @return HistoricalUsageServiceResponse
870 #
871 sub get_usage_service {
872 my ($self, %args) = @_;
873  
874 # parse inputs
875 my $_resource_path = '/stats/usage_by_service';
876  
877 my $_method = 'GET';
878 my $query_params = {};
879 my $header_params = {};
880 my $form_params = {};
881  
882 # 'Accept' and 'Content-Type' header
883 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
884 if ($_header_accept) {
885 $header_params->{'Accept'} = $_header_accept;
886 }
887 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
888  
889 # query params
890 if ( exists $args{'from'}) {
891 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
892 }
893  
894 # query params
895 if ( exists $args{'to'}) {
896 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
897 }
898  
899 my $_body_data;
900 # authentication setting, if any
901 my $auth_settings = [qw(token )];
902  
903 # make the API Call
904 my $response = $self->{api_client}->call_api($_resource_path, $_method,
905 $query_params, $form_params,
906 $header_params, $_body_data, $auth_settings);
907 if (!$response) {
908 return;
909 }
910 my $_response_object = $self->{api_client}->deserialize('HistoricalUsageServiceResponse', $response);
911 return $_response_object;
912 }
913  
914 1;