Fastly/AclApi.pm untested

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