Fastly/BillingUsageMetricsApi.pm untested

filter: Statementstmt 0.0% 0 / 100 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 156 CC 17 SCAR 40.0
CC
17
Cov
0%
get_service_level_usage
110.0
get_usage_metrics
56.0
new
6.0
CRAP 54.4
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::BillingUsageMetricsApi;
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_level_usage
51 #
52 # Retrieve service-level usage metrics for services with non-zero usage units.
53 #
54 # @param string $product_id The product identifier for the metrics returned (e.g., `cdn_usage`). This should be used along with `usage_type_name`. (optional)
55 # @param string $service The service identifier for the metrics being requested. (optional)
56 # @param string $usage_type_name The usage type name for the metrics returned (e.g., `North America Requests`). This should be used along with `product_id`. (optional)
57 # @param string $start_month (optional)
58 # @param string $end_month (optional)
59 # @param string $limit Number of results per page. The maximum is 10000. (optional, default to '1000')
60 # @param string $cursor Cursor value from the `next_cursor` field of a previous response, used to retrieve the next page. To request the first page, this should be empty. (optional)
61 {
62 my $params = {
63 'product_id' => {
64 data_type => 'string',
65 description => 'The product identifier for the metrics returned (e.g., `cdn_usage`). This should be used along with `usage_type_name`.',
66 required => '0',
67 },
68 'service' => {
69 data_type => 'string',
70 description => 'The service identifier for the metrics being requested.',
71 required => '0',
72 },
73 'usage_type_name' => {
74 data_type => 'string',
75 description => 'The usage type name for the metrics returned (e.g., `North America Requests`). This should be used along with `product_id`.',
76 required => '0',
77 },
78 'start_month' => {
79 data_type => 'string',
80 description => '',
81 required => '0',
82 },
83 'end_month' => {
84 data_type => 'string',
85 description => '',
86 required => '0',
87 },
88 'limit' => {
89 data_type => 'string',
90 description => 'Number of results per page. The maximum is 10000.',
91 required => '0',
92 },
93 'cursor' => {
94 data_type => 'string',
95 description => 'Cursor value from the `next_cursor` field of a previous response, used to retrieve the next page. To request the first page, this should be empty.',
96 required => '0',
97 },
98 };
99 __PACKAGE__->method_documentation->{ 'get_service_level_usage' } = {
100 summary => 'Retrieve service-level usage metrics for services with non-zero usage units.',
101 params => $params,
102 returns => 'Serviceusagemetrics',
103 };
104 }
105 # @return Serviceusagemetrics
106 #
107 sub get_service_level_usage {
108 my ($self, %args) = @_;
109  
110 # parse inputs
111 my $_resource_path = '/billing/v3/service-usage-metrics';
112  
113 my $_method = 'GET';
114 my $query_params = {};
115 my $header_params = {};
116 my $form_params = {};
117  
118 # 'Accept' and 'Content-Type' header
119 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
120 if ($_header_accept) {
121 $header_params->{'Accept'} = $_header_accept;
122 }
123 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
124  
125 # query params
126 if ( exists $args{'product_id'}) {
127 $query_params->{'product_id'} = $self->{api_client}->to_query_value($args{'product_id'});
128 }
129  
130 # query params
131 if ( exists $args{'service'}) {
132 $query_params->{'service'} = $self->{api_client}->to_query_value($args{'service'});
133 }
134  
135 # query params
136 if ( exists $args{'usage_type_name'}) {
137 $query_params->{'usage_type_name'} = $self->{api_client}->to_query_value($args{'usage_type_name'});
138 }
139  
140 # query params
141 if ( exists $args{'start_month'}) {
142 $query_params->{'start_month'} = $self->{api_client}->to_query_value($args{'start_month'});
143 }
144  
145 # query params
146 if ( exists $args{'end_month'}) {
147 $query_params->{'end_month'} = $self->{api_client}->to_query_value($args{'end_month'});
148 }
149  
150 # query params
151 if ( exists $args{'limit'}) {
152 $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
153 }
154  
155 # query params
156 if ( exists $args{'cursor'}) {
157 $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'});
158 }
159  
160 my $_body_data;
161 # authentication setting, if any
162 my $auth_settings = [qw(token )];
163  
164 # make the API Call
165 my $response = $self->{api_client}->call_api($_resource_path, $_method,
166 $query_params, $form_params,
167 $header_params, $_body_data, $auth_settings);
168 if (!$response) {
169 return;
170 }
171 my $_response_object = $self->{api_client}->deserialize('Serviceusagemetrics', $response);
172 return $_response_object;
173 }
174  
175 #
176 # get_usage_metrics
177 #
178 # Get monthly usage metrics
179 #
180 # @param string $start_month (required)
181 # @param string $end_month (required)
182 {
183 my $params = {
184 'start_month' => {
185 data_type => 'string',
186 description => '',
187 required => '1',
188 },
189 'end_month' => {
190 data_type => 'string',
191 description => '',
192 required => '1',
193 },
194 };
195 __PACKAGE__->method_documentation->{ 'get_usage_metrics' } = {
196 summary => 'Get monthly usage metrics',
197 params => $params,
198 returns => 'Usagemetric',
199 };
200 }
201 # @return Usagemetric
202 #
203 sub get_usage_metrics {
204 my ($self, %args) = @_;
205  
206 # verify the required parameter 'start_month' is set
207 unless (exists $args{'start_month'}) {
208 croak("Missing the required parameter 'start_month' when calling get_usage_metrics");
209 }
210  
211 # verify the required parameter 'end_month' is set
212 unless (exists $args{'end_month'}) {
213 croak("Missing the required parameter 'end_month' when calling get_usage_metrics");
214 }
215  
216 # parse inputs
217 my $_resource_path = '/billing/v3/usage-metrics';
218  
219 my $_method = 'GET';
220 my $query_params = {};
221 my $header_params = {};
222 my $form_params = {};
223  
224 # 'Accept' and 'Content-Type' header
225 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
226 if ($_header_accept) {
227 $header_params->{'Accept'} = $_header_accept;
228 }
229 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
230  
231 # query params
232 if ( exists $args{'start_month'}) {
233 $query_params->{'start_month'} = $self->{api_client}->to_query_value($args{'start_month'});
234 }
235  
236 # query params
237 if ( exists $args{'end_month'}) {
238 $query_params->{'end_month'} = $self->{api_client}->to_query_value($args{'end_month'});
239 }
240  
241 my $_body_data;
242 # authentication setting, if any
243 my $auth_settings = [qw(token )];
244  
245 # make the API Call
246 my $response = $self->{api_client}->call_api($_resource_path, $_method,
247 $query_params, $form_params,
248 $header_params, $_body_data, $auth_settings);
249 if (!$response) {
250 return;
251 }
252 my $_response_object = $self->{api_client}->deserialize('Usagemetric', $response);
253 return $_response_object;
254 }
255  
256 1;