Fastly/StatsApi.pm untested

filter: Statementstmt 0.0% 0 / 70 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 110 CC 10 SCAR 37.4
CC
10
Cov
0%
get_service_stats
90.0
new
6.0
BEGIN
2.0
CRAP 42.0
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::StatsApi;
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_service_stats
51 #
52 # Get stats for a service
53 #
54 # @param string $service_id Alphanumeric string identifying the service. (required)
55 # @param string $month 2-digit month. (optional)
56 # @param string $year 4-digit year. (optional)
57 # @param int $start_time Epoch timestamp. Limits the results returned. (optional)
58 # @param int $end_time Epoch timestamp. Limits the results returned. (optional)
59 {
60 my $params = {
61 'service_id' => {
62 data_type => 'string',
63 description => 'Alphanumeric string identifying the service.',
64 required => '1',
65 },
66 'month' => {
67 data_type => 'string',
68 description => '2-digit month.',
69 required => '0',
70 },
71 'year' => {
72 data_type => 'string',
73 description => '4-digit year.',
74 required => '0',
75 },
76 'start_time' => {
77 data_type => 'int',
78 description => 'Epoch timestamp. Limits the results returned.',
79 required => '0',
80 },
81 'end_time' => {
82 data_type => 'int',
83 description => 'Epoch timestamp. Limits the results returned.',
84 required => '0',
85 },
86 };
87 __PACKAGE__->method_documentation->{ 'get_service_stats' } = {
88 summary => 'Get stats for a service',
89 params => $params,
90 returns => 'Stats',
91 };
92 }
93 # @return Stats
94 #
95 sub get_service_stats {
96 my ($self, %args) = @_;
97  
98 # verify the required parameter 'service_id' is set
99 unless (exists $args{'service_id'}) {
100 croak("Missing the required parameter 'service_id' when calling get_service_stats");
101 }
102  
103 # parse inputs
104 my $_resource_path = '/service/{service_id}/stats/summary';
105  
106 my $_method = 'GET';
107 my $query_params = {};
108 my $header_params = {};
109 my $form_params = {};
110  
111 # 'Accept' and 'Content-Type' header
112 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
113 if ($_header_accept) {
114 $header_params->{'Accept'} = $_header_accept;
115 }
116 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
117  
118 # query params
119 if ( exists $args{'month'}) {
120 $query_params->{'month'} = $self->{api_client}->to_query_value($args{'month'});
121 }
122  
123 # query params
124 if ( exists $args{'year'}) {
125 $query_params->{'year'} = $self->{api_client}->to_query_value($args{'year'});
126 }
127  
128 # query params
129 if ( exists $args{'start_time'}) {
130 $query_params->{'start_time'} = $self->{api_client}->to_query_value($args{'start_time'});
131 }
132  
133 # query params
134 if ( exists $args{'end_time'}) {
135 $query_params->{'end_time'} = $self->{api_client}->to_query_value($args{'end_time'});
136 }
137  
138 # path params
139 if ( exists $args{'service_id'}) {
140 my $_base_variable = "{" . "service_id" . "}";
141 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
142 $_resource_path =~ s/$_base_variable/$_base_value/g;
143 }
144  
145 my $_body_data;
146 # authentication setting, if any
147 my $auth_settings = [qw(token )];
148  
149 # make the API Call
150 my $response = $self->{api_client}->call_api($_resource_path, $_method,
151 $query_params, $form_params,
152 $header_params, $_body_data, $auth_settings);
153 if (!$response) {
154 return;
155 }
156 my $_response_object = $self->{api_client}->deserialize('Stats', $response);
157 return $_response_object;
158 }
159  
160 1;