Fastly/MetricsPlatformApi.pm untested

filter: Statementstmt 0.0% 0 / 132 Branchbran 0.0% 0 / 58 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 / 214 CC 30 SCAR 51.9
CC
30
Cov
0%
get_platform_metrics_entity_historical
272.0
get_platform_metrics_aggregate_historical
210.0
new
6.0
CRAP 178.6
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::MetricsPlatformApi;
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_platform_metrics_aggregate_historical
51 #
52 # Get aggregated historical time series metrics for all entities
53 #
54 # @param string $granularity Duration of sample windows. (required)
55 # @param string $from A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional)
56 # @param string $to A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional)
57 # @param string $metric One or more metrics to retrieve. Multiple values should be comma-separated. (optional)
58 # @param string $metric_set One or more metric sets to retrieve. Multiple values should be comma-separated. A metric set expands to a list of metrics; see the Metric Sets section above for the metrics in each set. A metric that appears in more than one requested set is returned once. (optional)
59 # @param string $group_by Field to group_by in the query. For example, `group_by=region` will return entries for grouped by timestamp and region. (optional)
60 # @param string $region Limit query to one or more specific geographic regions. Values should be comma-separated. (optional)
61 # @param string $datacenter Limit query to one or more specific POPs. Values should be comma-separated. (optional)
62 # @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)
63 # @param string $limit Number of results per page. The maximum is 10000. (optional, default to '1000')
64 {
65 my $params = {
66 'granularity' => {
67 data_type => 'string',
68 description => 'Duration of sample windows.',
69 required => '1',
70 },
71 'from' => {
72 data_type => 'string',
73 description => 'A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value.',
74 required => '0',
75 },
76 'to' => {
77 data_type => 'string',
78 description => 'A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value.',
79 required => '0',
80 },
81 'metric' => {
82 data_type => 'string',
83 description => 'One or more metrics to retrieve. Multiple values should be comma-separated.',
84 required => '0',
85 },
86 'metric_set' => {
87 data_type => 'string',
88 description => 'One or more metric sets to retrieve. Multiple values should be comma-separated. A metric set expands to a list of metrics; see the Metric Sets section above for the metrics in each set. A metric that appears in more than one requested set is returned once. ',
89 required => '0',
90 },
91 'group_by' => {
92 data_type => 'string',
93 description => 'Field to group_by in the query. For example, `group_by=region` will return entries for grouped by timestamp and region. ',
94 required => '0',
95 },
96 'region' => {
97 data_type => 'string',
98 description => 'Limit query to one or more specific geographic regions. Values should be comma-separated. ',
99 required => '0',
100 },
101 'datacenter' => {
102 data_type => 'string',
103 description => 'Limit query to one or more specific POPs. Values should be comma-separated.',
104 required => '0',
105 },
106 'cursor' => {
107 data_type => 'string',
108 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.',
109 required => '0',
110 },
111 'limit' => {
112 data_type => 'string',
113 description => 'Number of results per page. The maximum is 10000.',
114 required => '0',
115 },
116 };
117 __PACKAGE__->method_documentation->{ 'get_platform_metrics_aggregate_historical' } = {
118 summary => 'Get aggregated historical time series metrics for all entities',
119 params => $params,
120 returns => 'PlatformMetricsResponse',
121 };
122 }
123 # @return PlatformMetricsResponse
124 #
125 sub get_platform_metrics_aggregate_historical {
126 my ($self, %args) = @_;
127  
128 # verify the required parameter 'granularity' is set
129 unless (exists $args{'granularity'}) {
130 croak("Missing the required parameter 'granularity' when calling get_platform_metrics_aggregate_historical");
131 }
132  
133 # parse inputs
134 my $_resource_path = '/metrics/v2/platform/aggregate/{granularity}';
135  
136 my $_method = 'GET';
137 my $query_params = {};
138 my $header_params = {};
139 my $form_params = {};
140  
141 # 'Accept' and 'Content-Type' header
142 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
143 if ($_header_accept) {
144 $header_params->{'Accept'} = $_header_accept;
145 }
146 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
147  
148 # query params
149 if ( exists $args{'from'}) {
150 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
151 }
152  
153 # query params
154 if ( exists $args{'to'}) {
155 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
156 }
157  
158 # query params
159 if ( exists $args{'metric'}) {
160 $query_params->{'metric'} = $self->{api_client}->to_query_value($args{'metric'});
161 }
162  
163 # query params
164 if ( exists $args{'metric_set'}) {
165 $query_params->{'metric_set'} = $self->{api_client}->to_query_value($args{'metric_set'});
166 }
167  
168 # query params
169 if ( exists $args{'group_by'}) {
170 $query_params->{'group_by'} = $self->{api_client}->to_query_value($args{'group_by'});
171 }
172  
173 # query params
174 if ( exists $args{'region'}) {
175 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
176 }
177  
178 # query params
179 if ( exists $args{'datacenter'}) {
180 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
181 }
182  
183 # query params
184 if ( exists $args{'cursor'}) {
185 $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'});
186 }
187  
188 # query params
189 if ( exists $args{'limit'}) {
190 $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
191 }
192  
193 # path params
194 if ( exists $args{'granularity'}) {
195 my $_base_variable = "{" . "granularity" . "}";
196 my $_base_value = $self->{api_client}->to_path_value($args{'granularity'});
197 $_resource_path =~ s/$_base_variable/$_base_value/g;
198 }
199  
200 my $_body_data;
201 # authentication setting, if any
202 my $auth_settings = [qw(token )];
203  
204 # make the API Call
205 my $response = $self->{api_client}->call_api($_resource_path, $_method,
206 $query_params, $form_params,
207 $header_params, $_body_data, $auth_settings);
208 if (!$response) {
209 return;
210 }
211 my $_response_object = $self->{api_client}->deserialize('PlatformMetricsResponse', $response);
212 return $_response_object;
213 }
214  
215 #
216 # get_platform_metrics_entity_historical
217 #
218 # Get historical time series metrics for a single entity.
219 #
220 # @param string $entity_id Alphanumeric string identifying the entity. (required)
221 # @param string $granularity Duration of sample windows. (required)
222 # @param string $from A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional)
223 # @param string $to A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional)
224 # @param string $metric One or more metrics to retrieve. Multiple values should be comma-separated. (optional)
225 # @param string $metric_set One or more metric sets to retrieve. Multiple values should be comma-separated. A metric set expands to a list of metrics; see the Metric Sets section above for the metrics in each set. A metric that appears in more than one requested set is returned once. (optional)
226 # @param string $group_by Field to group_by in the query. For example, `group_by=region` will return entries for grouped by timestamp and region. (optional)
227 # @param string $region Limit query to one or more specific geographic regions. Values should be comma-separated. (optional)
228 # @param string $datacenter Limit query to one or more specific POPs. Values should be comma-separated. (optional)
229 # @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)
230 # @param string $limit Number of results per page. The maximum is 10000. (optional, default to '1000')
231 {
232 my $params = {
233 'entity_id' => {
234 data_type => 'string',
235 description => 'Alphanumeric string identifying the entity.',
236 required => '1',
237 },
238 'granularity' => {
239 data_type => 'string',
240 description => 'Duration of sample windows.',
241 required => '1',
242 },
243 'from' => {
244 data_type => 'string',
245 description => 'A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value.',
246 required => '0',
247 },
248 'to' => {
249 data_type => 'string',
250 description => 'A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value.',
251 required => '0',
252 },
253 'metric' => {
254 data_type => 'string',
255 description => 'One or more metrics to retrieve. Multiple values should be comma-separated.',
256 required => '0',
257 },
258 'metric_set' => {
259 data_type => 'string',
260 description => 'One or more metric sets to retrieve. Multiple values should be comma-separated. A metric set expands to a list of metrics; see the Metric Sets section above for the metrics in each set. A metric that appears in more than one requested set is returned once. ',
261 required => '0',
262 },
263 'group_by' => {
264 data_type => 'string',
265 description => 'Field to group_by in the query. For example, `group_by=region` will return entries for grouped by timestamp and region. ',
266 required => '0',
267 },
268 'region' => {
269 data_type => 'string',
270 description => 'Limit query to one or more specific geographic regions. Values should be comma-separated. ',
271 required => '0',
272 },
273 'datacenter' => {
274 data_type => 'string',
275 description => 'Limit query to one or more specific POPs. Values should be comma-separated.',
276 required => '0',
277 },
278 'cursor' => {
279 data_type => 'string',
280 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.',
281 required => '0',
282 },
283 'limit' => {
284 data_type => 'string',
285 description => 'Number of results per page. The maximum is 10000.',
286 required => '0',
287 },
288 };
289 __PACKAGE__->method_documentation->{ 'get_platform_metrics_entity_historical' } = {
290 summary => 'Get historical time series metrics for a single entity.',
291 params => $params,
292 returns => 'PlatformMetricsResponse',
293 };
294 }
295 # @return PlatformMetricsResponse
296 #
297 sub get_platform_metrics_entity_historical {
298 my ($self, %args) = @_;
299  
300 # verify the required parameter 'entity_id' is set
301 unless (exists $args{'entity_id'}) {
302 croak("Missing the required parameter 'entity_id' when calling get_platform_metrics_entity_historical");
303 }
304  
305 # verify the required parameter 'granularity' is set
306 unless (exists $args{'granularity'}) {
307 croak("Missing the required parameter 'granularity' when calling get_platform_metrics_entity_historical");
308 }
309  
310 # parse inputs
311 my $_resource_path = '/metrics/v2/platform/entities/{entity_id}/{granularity}';
312  
313 my $_method = 'GET';
314 my $query_params = {};
315 my $header_params = {};
316 my $form_params = {};
317  
318 # 'Accept' and 'Content-Type' header
319 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
320 if ($_header_accept) {
321 $header_params->{'Accept'} = $_header_accept;
322 }
323 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
324  
325 # query params
326 if ( exists $args{'from'}) {
327 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
328 }
329  
330 # query params
331 if ( exists $args{'to'}) {
332 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
333 }
334  
335 # query params
336 if ( exists $args{'metric'}) {
337 $query_params->{'metric'} = $self->{api_client}->to_query_value($args{'metric'});
338 }
339  
340 # query params
341 if ( exists $args{'metric_set'}) {
342 $query_params->{'metric_set'} = $self->{api_client}->to_query_value($args{'metric_set'});
343 }
344  
345 # query params
346 if ( exists $args{'group_by'}) {
347 $query_params->{'group_by'} = $self->{api_client}->to_query_value($args{'group_by'});
348 }
349  
350 # query params
351 if ( exists $args{'region'}) {
352 $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'});
353 }
354  
355 # query params
356 if ( exists $args{'datacenter'}) {
357 $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'});
358 }
359  
360 # query params
361 if ( exists $args{'cursor'}) {
362 $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'});
363 }
364  
365 # query params
366 if ( exists $args{'limit'}) {
367 $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
368 }
369  
370 # path params
371 if ( exists $args{'entity_id'}) {
372 my $_base_variable = "{" . "entity_id" . "}";
373 my $_base_value = $self->{api_client}->to_path_value($args{'entity_id'});
374 $_resource_path =~ s/$_base_variable/$_base_value/g;
375 }
376  
377 # path params
378 if ( exists $args{'granularity'}) {
379 my $_base_variable = "{" . "granularity" . "}";
380 my $_base_value = $self->{api_client}->to_path_value($args{'granularity'});
381 $_resource_path =~ s/$_base_variable/$_base_value/g;
382 }
383  
384 my $_body_data;
385 # authentication setting, if any
386 my $auth_settings = [qw(token )];
387  
388 # make the API Call
389 my $response = $self->{api_client}->call_api($_resource_path, $_method,
390 $query_params, $form_params,
391 $header_params, $_body_data, $auth_settings);
392 if (!$response) {
393 return;
394 }
395 my $_response_object = $self->{api_client}->deserialize('PlatformMetricsResponse', $response);
396 return $_response_object;
397 }
398  
399 1;