Fastly/DdosProtectionApi.pm untested

filter: Statementstmt 0.0% 0 / 222 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 324 CC 36 SCAR 38.3
CC
36
Cov
0%
ddos_protection_event_list
90.0
ddos_protection_event_rule_list
72.0
ddos_protection_traffic_stats_rule_get
56.0
CRAP 46.3
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::DdosProtectionApi;
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 # ddos_protection_event_get
51 #
52 # Get event by ID
53 #
54 # @param string $event_id Unique ID of the event. (required)
55 {
56 my $params = {
57 'event_id' => {
58 data_type => 'string',
59 description => 'Unique ID of the event.',
60 required => '1',
61 },
62 };
63 __PACKAGE__->method_documentation->{ 'ddos_protection_event_get' } = {
64 summary => 'Get event by ID',
65 params => $params,
66 returns => 'DdosProtectionEvent',
67 };
68 }
69 # @return DdosProtectionEvent
70 #
71 sub ddos_protection_event_get {
72 my ($self, %args) = @_;
73  
74 # verify the required parameter 'event_id' is set
75 unless (exists $args{'event_id'}) {
76 croak("Missing the required parameter 'event_id' when calling ddos_protection_event_get");
77 }
78  
79 # parse inputs
80 my $_resource_path = '/ddos-protection/v1/events/{event_id}';
81  
82 my $_method = 'GET';
83 my $query_params = {};
84 my $header_params = {};
85 my $form_params = {};
86  
87 # 'Accept' and 'Content-Type' header
88 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
89 if ($_header_accept) {
90 $header_params->{'Accept'} = $_header_accept;
91 }
92 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
93  
94 # path params
95 if ( exists $args{'event_id'}) {
96 my $_base_variable = "{" . "event_id" . "}";
97 my $_base_value = $self->{api_client}->to_path_value($args{'event_id'});
98 $_resource_path =~ s/$_base_variable/$_base_value/g;
99 }
100  
101 my $_body_data;
102 # authentication setting, if any
103 my $auth_settings = [qw(token )];
104  
105 # make the API Call
106 my $response = $self->{api_client}->call_api($_resource_path, $_method,
107 $query_params, $form_params,
108 $header_params, $_body_data, $auth_settings);
109 if (!$response) {
110 return;
111 }
112 my $_response_object = $self->{api_client}->deserialize('DdosProtectionEvent', $response);
113 return $_response_object;
114 }
115  
116 #
117 # ddos_protection_event_list
118 #
119 # Get events
120 #
121 # @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)
122 # @param int $limit Limit how many results are returned. (optional, default to 20)
123 # @param string $service_id Filter results based on a service_id. (optional)
124 # @param DateTime $from Represents the start of a date-time range expressed in RFC 3339 format. (optional)
125 # @param DateTime $to Represents the end of a date-time range expressed in RFC 3339 format. (optional)
126 # @param string $name (optional)
127 {
128 my $params = {
129 'cursor' => {
130 data_type => 'string',
131 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.',
132 required => '0',
133 },
134 'limit' => {
135 data_type => 'int',
136 description => 'Limit how many results are returned.',
137 required => '0',
138 },
139 'service_id' => {
140 data_type => 'string',
141 description => 'Filter results based on a service_id.',
142 required => '0',
143 },
144 'from' => {
145 data_type => 'DateTime',
146 description => 'Represents the start of a date-time range expressed in RFC 3339 format.',
147 required => '0',
148 },
149 'to' => {
150 data_type => 'DateTime',
151 description => 'Represents the end of a date-time range expressed in RFC 3339 format.',
152 required => '0',
153 },
154 'name' => {
155 data_type => 'string',
156 description => '',
157 required => '0',
158 },
159 };
160 __PACKAGE__->method_documentation->{ 'ddos_protection_event_list' } = {
161 summary => 'Get events',
162 params => $params,
163 returns => 'InlineResponse20012',
164 };
165 }
166 # @return InlineResponse20012
167 #
168 sub ddos_protection_event_list {
169 my ($self, %args) = @_;
170  
171 # parse inputs
172 my $_resource_path = '/ddos-protection/v1/events';
173  
174 my $_method = 'GET';
175 my $query_params = {};
176 my $header_params = {};
177 my $form_params = {};
178  
179 # 'Accept' and 'Content-Type' header
180 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
181 if ($_header_accept) {
182 $header_params->{'Accept'} = $_header_accept;
183 }
184 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
185  
186 # query params
187 if ( exists $args{'cursor'}) {
188 $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'});
189 }
190  
191 # query params
192 if ( exists $args{'limit'}) {
193 $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
194 }
195  
196 # query params
197 if ( exists $args{'service_id'}) {
198 $query_params->{'service_id'} = $self->{api_client}->to_query_value($args{'service_id'});
199 }
200  
201 # query params
202 if ( exists $args{'from'}) {
203 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
204 }
205  
206 # query params
207 if ( exists $args{'to'}) {
208 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
209 }
210  
211 # query params
212 if ( exists $args{'name'}) {
213 $query_params->{'name'} = $self->{api_client}->to_query_value($args{'name'});
214 }
215  
216 my $_body_data;
217 # authentication setting, if any
218 my $auth_settings = [qw(token )];
219  
220 # make the API Call
221 my $response = $self->{api_client}->call_api($_resource_path, $_method,
222 $query_params, $form_params,
223 $header_params, $_body_data, $auth_settings);
224 if (!$response) {
225 return;
226 }
227 my $_response_object = $self->{api_client}->deserialize('InlineResponse20012', $response);
228 return $_response_object;
229 }
230  
231 #
232 # ddos_protection_event_rule_list
233 #
234 # Get all rules for an event
235 #
236 # @param string $event_id Unique ID of the event. (required)
237 # @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)
238 # @param int $limit Limit how many results are returned. (optional, default to 20)
239 # @param string $include Include relationships. Optional. Comma-separated values. (optional)
240 {
241 my $params = {
242 'event_id' => {
243 data_type => 'string',
244 description => 'Unique ID of the event.',
245 required => '1',
246 },
247 'cursor' => {
248 data_type => 'string',
249 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.',
250 required => '0',
251 },
252 'limit' => {
253 data_type => 'int',
254 description => 'Limit how many results are returned.',
255 required => '0',
256 },
257 'include' => {
258 data_type => 'string',
259 description => 'Include relationships. Optional. Comma-separated values.',
260 required => '0',
261 },
262 };
263 __PACKAGE__->method_documentation->{ 'ddos_protection_event_rule_list' } = {
264 summary => 'Get all rules for an event',
265 params => $params,
266 returns => 'InlineResponse20013',
267 };
268 }
269 # @return InlineResponse20013
270 #
271 sub ddos_protection_event_rule_list {
272 my ($self, %args) = @_;
273  
274 # verify the required parameter 'event_id' is set
275 unless (exists $args{'event_id'}) {
276 croak("Missing the required parameter 'event_id' when calling ddos_protection_event_rule_list");
277 }
278  
279 # parse inputs
280 my $_resource_path = '/ddos-protection/v1/events/{event_id}/rules';
281  
282 my $_method = 'GET';
283 my $query_params = {};
284 my $header_params = {};
285 my $form_params = {};
286  
287 # 'Accept' and 'Content-Type' header
288 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
289 if ($_header_accept) {
290 $header_params->{'Accept'} = $_header_accept;
291 }
292 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
293  
294 # query params
295 if ( exists $args{'cursor'}) {
296 $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'});
297 }
298  
299 # query params
300 if ( exists $args{'limit'}) {
301 $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
302 }
303  
304 # query params
305 if ( exists $args{'include'}) {
306 $query_params->{'include'} = $self->{api_client}->to_query_value($args{'include'});
307 }
308  
309 # path params
310 if ( exists $args{'event_id'}) {
311 my $_base_variable = "{" . "event_id" . "}";
312 my $_base_value = $self->{api_client}->to_path_value($args{'event_id'});
313 $_resource_path =~ s/$_base_variable/$_base_value/g;
314 }
315  
316 my $_body_data;
317 # authentication setting, if any
318 my $auth_settings = [qw(token )];
319  
320 # make the API Call
321 my $response = $self->{api_client}->call_api($_resource_path, $_method,
322 $query_params, $form_params,
323 $header_params, $_body_data, $auth_settings);
324 if (!$response) {
325 return;
326 }
327 my $_response_object = $self->{api_client}->deserialize('InlineResponse20013', $response);
328 return $_response_object;
329 }
330  
331 #
332 # ddos_protection_rule_get
333 #
334 # Get a rule by ID
335 #
336 # @param string $rule_id Unique ID of the rule. (required)
337 {
338 my $params = {
339 'rule_id' => {
340 data_type => 'string',
341 description => 'Unique ID of the rule.',
342 required => '1',
343 },
344 };
345 __PACKAGE__->method_documentation->{ 'ddos_protection_rule_get' } = {
346 summary => 'Get a rule by ID',
347 params => $params,
348 returns => 'DdosProtectionRule',
349 };
350 }
351 # @return DdosProtectionRule
352 #
353 sub ddos_protection_rule_get {
354 my ($self, %args) = @_;
355  
356 # verify the required parameter 'rule_id' is set
357 unless (exists $args{'rule_id'}) {
358 croak("Missing the required parameter 'rule_id' when calling ddos_protection_rule_get");
359 }
360  
361 # parse inputs
362 my $_resource_path = '/ddos-protection/v1/rules/{rule_id}';
363  
364 my $_method = 'GET';
365 my $query_params = {};
366 my $header_params = {};
367 my $form_params = {};
368  
369 # 'Accept' and 'Content-Type' header
370 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
371 if ($_header_accept) {
372 $header_params->{'Accept'} = $_header_accept;
373 }
374 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
375  
376 # path params
377 if ( exists $args{'rule_id'}) {
378 my $_base_variable = "{" . "rule_id" . "}";
379 my $_base_value = $self->{api_client}->to_path_value($args{'rule_id'});
380 $_resource_path =~ s/$_base_variable/$_base_value/g;
381 }
382  
383 my $_body_data;
384 # authentication setting, if any
385 my $auth_settings = [qw(token )];
386  
387 # make the API Call
388 my $response = $self->{api_client}->call_api($_resource_path, $_method,
389 $query_params, $form_params,
390 $header_params, $_body_data, $auth_settings);
391 if (!$response) {
392 return;
393 }
394 my $_response_object = $self->{api_client}->deserialize('DdosProtectionRule', $response);
395 return $_response_object;
396 }
397  
398 #
399 # ddos_protection_rule_patch
400 #
401 # Update rule
402 #
403 # @param string $rule_id Unique ID of the rule. (required)
404 # @param DdosProtectionRulePatch $ddos_protection_rule_patch (optional)
405 {
406 my $params = {
407 'rule_id' => {
408 data_type => 'string',
409 description => 'Unique ID of the rule.',
410 required => '1',
411 },
412 'ddos_protection_rule_patch' => {
413 data_type => 'DdosProtectionRulePatch',
414 description => '',
415 required => '0',
416 },
417 };
418 __PACKAGE__->method_documentation->{ 'ddos_protection_rule_patch' } = {
419 summary => 'Update rule',
420 params => $params,
421 returns => 'DdosProtectionRule',
422 };
423 }
424 # @return DdosProtectionRule
425 #
426 sub ddos_protection_rule_patch {
427 my ($self, %args) = @_;
428  
429 # verify the required parameter 'rule_id' is set
430 unless (exists $args{'rule_id'}) {
431 croak("Missing the required parameter 'rule_id' when calling ddos_protection_rule_patch");
432 }
433  
434 # parse inputs
435 my $_resource_path = '/ddos-protection/v1/rules/{rule_id}';
436  
437 my $_method = 'PATCH';
438 my $query_params = {};
439 my $header_params = {};
440 my $form_params = {};
441  
442 # 'Accept' and 'Content-Type' header
443 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
444 if ($_header_accept) {
445 $header_params->{'Accept'} = $_header_accept;
446 }
447 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
448  
449 # path params
450 if ( exists $args{'rule_id'}) {
451 my $_base_variable = "{" . "rule_id" . "}";
452 my $_base_value = $self->{api_client}->to_path_value($args{'rule_id'});
453 $_resource_path =~ s/$_base_variable/$_base_value/g;
454 }
455  
456 my $_body_data;
457 # body params
458 if ( exists $args{'ddos_protection_rule_patch'}) {
459 $_body_data = $args{'ddos_protection_rule_patch'};
460 }
461  
462 # authentication setting, if any
463 my $auth_settings = [qw(token )];
464  
465 # make the API Call
466 my $response = $self->{api_client}->call_api($_resource_path, $_method,
467 $query_params, $form_params,
468 $header_params, $_body_data, $auth_settings);
469 if (!$response) {
470 return;
471 }
472 my $_response_object = $self->{api_client}->deserialize('DdosProtectionRule', $response);
473 return $_response_object;
474 }
475  
476 #
477 # ddos_protection_traffic_stats_rule_get
478 #
479 # Get traffic stats for a rule
480 #
481 # @param string $event_id Unique ID of the event. (required)
482 # @param string $rule_id Unique ID of the rule. (required)
483 {
484 my $params = {
485 'event_id' => {
486 data_type => 'string',
487 description => 'Unique ID of the event.',
488 required => '1',
489 },
490 'rule_id' => {
491 data_type => 'string',
492 description => 'Unique ID of the rule.',
493 required => '1',
494 },
495 };
496 __PACKAGE__->method_documentation->{ 'ddos_protection_traffic_stats_rule_get' } = {
497 summary => 'Get traffic stats for a rule',
498 params => $params,
499 returns => 'DdosProtectionTrafficStats',
500 };
501 }
502 # @return DdosProtectionTrafficStats
503 #
504 sub ddos_protection_traffic_stats_rule_get {
505 my ($self, %args) = @_;
506  
507 # verify the required parameter 'event_id' is set
508 unless (exists $args{'event_id'}) {
509 croak("Missing the required parameter 'event_id' when calling ddos_protection_traffic_stats_rule_get");
510 }
511  
512 # verify the required parameter 'rule_id' is set
513 unless (exists $args{'rule_id'}) {
514 croak("Missing the required parameter 'rule_id' when calling ddos_protection_traffic_stats_rule_get");
515 }
516  
517 # parse inputs
518 my $_resource_path = '/ddos-protection/v1/events/{event_id}/rules/{rule_id}/traffic-stats';
519  
520 my $_method = 'GET';
521 my $query_params = {};
522 my $header_params = {};
523 my $form_params = {};
524  
525 # 'Accept' and 'Content-Type' header
526 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
527 if ($_header_accept) {
528 $header_params->{'Accept'} = $_header_accept;
529 }
530 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
531  
532 # path params
533 if ( exists $args{'event_id'}) {
534 my $_base_variable = "{" . "event_id" . "}";
535 my $_base_value = $self->{api_client}->to_path_value($args{'event_id'});
536 $_resource_path =~ s/$_base_variable/$_base_value/g;
537 }
538  
539 # path params
540 if ( exists $args{'rule_id'}) {
541 my $_base_variable = "{" . "rule_id" . "}";
542 my $_base_value = $self->{api_client}->to_path_value($args{'rule_id'});
543 $_resource_path =~ s/$_base_variable/$_base_value/g;
544 }
545  
546 my $_body_data;
547 # authentication setting, if any
548 my $auth_settings = [qw(token )];
549  
550 # make the API Call
551 my $response = $self->{api_client}->call_api($_resource_path, $_method,
552 $query_params, $form_params,
553 $header_params, $_body_data, $auth_settings);
554 if (!$response) {
555 return;
556 }
557 my $_response_object = $self->{api_client}->deserialize('DdosProtectionTrafficStats', $response);
558 return $_response_object;
559 }
560  
561 1;