Fastly/UserApi.pm untested

filter: Statementstmt 0.0% 0 / 251 Branchbran 0.0% 0 / 86 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 371 CC 44 SCAR 45.1
CC
44
Cov
0%
update_user
210.0
create_user
156.0
delete_user
30.0
CRAP 91.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::UserApi;
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_user
51 #
52 # Create a user
53 #
54 # @param string $login (optional)
55 # @param string $name The real life name of the user. (optional)
56 # @param boolean $limit_services Indicates that the user has limited access to the customer's services. (optional)
57 # @param boolean $locked Indicates whether the is account is locked for editing or not. (optional)
58 # @param boolean $require_new_password Indicates if a new password is required at next login. (optional)
59 # @param RoleUser $role (optional)
60 # @param ARRAY[string] $roles A list of role IDs assigned to the user. (optional)
61 # @param boolean $two_factor_auth_enabled Indicates if 2FA is enabled on the user. (optional)
62 # @param boolean $two_factor_setup_required Indicates if 2FA is required by the user's customer account. (optional)
63 {
64 my $params = {
65 'login' => {
66 data_type => 'string',
67 description => '',
68 required => '0',
69 },
70 'name' => {
71 data_type => 'string',
72 description => 'The real life name of the user.',
73 required => '0',
74 },
75 'limit_services' => {
76 data_type => 'boolean',
77 description => 'Indicates that the user has limited access to the customer's services.',
78 required => '0',
79 },
80 'locked' => {
81 data_type => 'boolean',
82 description => 'Indicates whether the is account is locked for editing or not.',
83 required => '0',
84 },
85 'require_new_password' => {
86 data_type => 'boolean',
87 description => 'Indicates if a new password is required at next login.',
88 required => '0',
89 },
90 'role' => {
91 data_type => 'RoleUser',
92 description => '',
93 required => '0',
94 },
95 'roles' => {
96 data_type => 'ARRAY[string]',
97 description => 'A list of role IDs assigned to the user.',
98 required => '0',
99 },
100 'two_factor_auth_enabled' => {
101 data_type => 'boolean',
102 description => 'Indicates if 2FA is enabled on the user.',
103 required => '0',
104 },
105 'two_factor_setup_required' => {
106 data_type => 'boolean',
107 description => 'Indicates if 2FA is required by the user's customer account.',
108 required => '0',
109 },
110 };
111 __PACKAGE__->method_documentation->{ 'create_user' } = {
112 summary => 'Create a user',
113 params => $params,
114 returns => 'UserResponse',
115 };
116 }
117 # @return UserResponse
118 #
119 sub create_user {
120 my ($self, %args) = @_;
121  
122 # parse inputs
123 my $_resource_path = '/user';
124  
125 my $_method = 'POST';
126 my $query_params = {};
127 my $header_params = {};
128 my $form_params = {};
129  
130 # 'Accept' and 'Content-Type' header
131 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
132 if ($_header_accept) {
133 $header_params->{'Accept'} = $_header_accept;
134 }
135 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
136  
137 # form params
138 if ( exists $args{'login'} ) {
139 $form_params->{'login'} = $self->{api_client}->to_form_value($args{'login'});
140 }
141  
142 # form params
143 if ( exists $args{'name'} ) {
144 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
145 }
146  
147 # form params
148 if ( exists $args{'limit_services'} ) {
149 $form_params->{'limit_services'} = $self->{api_client}->to_form_value($args{'limit_services'});
150 }
151  
152 # form params
153 if ( exists $args{'locked'} ) {
154 $form_params->{'locked'} = $self->{api_client}->to_form_value($args{'locked'});
155 }
156  
157 # form params
158 if ( exists $args{'require_new_password'} ) {
159 $form_params->{'require_new_password'} = $self->{api_client}->to_form_value($args{'require_new_password'});
160 }
161  
162 # form params
163 if ( exists $args{'role'} ) {
164 $form_params->{'role'} = $self->{api_client}->to_form_value($args{'role'});
165 }
166  
167 # form params
168 if ( exists $args{'roles'} ) {
169 $form_params->{'roles'} = $self->{api_client}->to_form_value($args{'roles'});
170 }
171  
172 # form params
173 if ( exists $args{'two_factor_auth_enabled'} ) {
174 $form_params->{'two_factor_auth_enabled'} = $self->{api_client}->to_form_value($args{'two_factor_auth_enabled'});
175 }
176  
177 # form params
178 if ( exists $args{'two_factor_setup_required'} ) {
179 $form_params->{'two_factor_setup_required'} = $self->{api_client}->to_form_value($args{'two_factor_setup_required'});
180 }
181  
182 my $_body_data;
183 # authentication setting, if any
184 my $auth_settings = [qw(token )];
185  
186 # make the API Call
187 my $response = $self->{api_client}->call_api($_resource_path, $_method,
188 $query_params, $form_params,
189 $header_params, $_body_data, $auth_settings);
190 if (!$response) {
191 return;
192 }
193 my $_response_object = $self->{api_client}->deserialize('UserResponse', $response);
194 return $_response_object;
195 }
196  
197 #
198 # delete_user
199 #
200 # Delete a user
201 #
202 # @param string $user_id Alphanumeric string identifying the user. (required)
203 {
204 my $params = {
205 'user_id' => {
206 data_type => 'string',
207 description => 'Alphanumeric string identifying the user.',
208 required => '1',
209 },
210 };
211 __PACKAGE__->method_documentation->{ 'delete_user' } = {
212 summary => 'Delete a user',
213 params => $params,
214 returns => 'InlineResponse200',
215 };
216 }
217 # @return InlineResponse200
218 #
219 sub delete_user {
220 my ($self, %args) = @_;
221  
222 # verify the required parameter 'user_id' is set
223 unless (exists $args{'user_id'}) {
224 croak("Missing the required parameter 'user_id' when calling delete_user");
225 }
226  
227 # parse inputs
228 my $_resource_path = '/user/{user_id}';
229  
230 my $_method = 'DELETE';
231 my $query_params = {};
232 my $header_params = {};
233 my $form_params = {};
234  
235 # 'Accept' and 'Content-Type' header
236 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
237 if ($_header_accept) {
238 $header_params->{'Accept'} = $_header_accept;
239 }
240 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
241  
242 # path params
243 if ( exists $args{'user_id'}) {
244 my $_base_variable = "{" . "user_id" . "}";
245 my $_base_value = $self->{api_client}->to_path_value($args{'user_id'});
246 $_resource_path =~ s/$_base_variable/$_base_value/g;
247 }
248  
249 my $_body_data;
250 # authentication setting, if any
251 my $auth_settings = [qw(token )];
252  
253 # make the API Call
254 my $response = $self->{api_client}->call_api($_resource_path, $_method,
255 $query_params, $form_params,
256 $header_params, $_body_data, $auth_settings);
257 if (!$response) {
258 return;
259 }
260 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
261 return $_response_object;
262 }
263  
264 #
265 # get_current_user
266 #
267 # Get the current user
268 #
269 {
270 my $params = {
271 };
272 __PACKAGE__->method_documentation->{ 'get_current_user' } = {
273 summary => 'Get the current user',
274 params => $params,
275 returns => 'UserResponse',
276 };
277 }
278 # @return UserResponse
279 #
280 sub get_current_user {
281 my ($self, %args) = @_;
282  
283 # parse inputs
284 my $_resource_path = '/current_user';
285  
286 my $_method = 'GET';
287 my $query_params = {};
288 my $header_params = {};
289 my $form_params = {};
290  
291 # 'Accept' and 'Content-Type' header
292 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
293 if ($_header_accept) {
294 $header_params->{'Accept'} = $_header_accept;
295 }
296 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
297  
298 my $_body_data;
299 # authentication setting, if any
300 my $auth_settings = [qw(token )];
301  
302 # make the API Call
303 my $response = $self->{api_client}->call_api($_resource_path, $_method,
304 $query_params, $form_params,
305 $header_params, $_body_data, $auth_settings);
306 if (!$response) {
307 return;
308 }
309 my $_response_object = $self->{api_client}->deserialize('UserResponse', $response);
310 return $_response_object;
311 }
312  
313 #
314 # get_user
315 #
316 # Get a user
317 #
318 # @param string $user_id Alphanumeric string identifying the user. (required)
319 {
320 my $params = {
321 'user_id' => {
322 data_type => 'string',
323 description => 'Alphanumeric string identifying the user.',
324 required => '1',
325 },
326 };
327 __PACKAGE__->method_documentation->{ 'get_user' } = {
328 summary => 'Get a user',
329 params => $params,
330 returns => 'UserResponse',
331 };
332 }
333 # @return UserResponse
334 #
335 sub get_user {
336 my ($self, %args) = @_;
337  
338 # verify the required parameter 'user_id' is set
339 unless (exists $args{'user_id'}) {
340 croak("Missing the required parameter 'user_id' when calling get_user");
341 }
342  
343 # parse inputs
344 my $_resource_path = '/user/{user_id}';
345  
346 my $_method = 'GET';
347 my $query_params = {};
348 my $header_params = {};
349 my $form_params = {};
350  
351 # 'Accept' and 'Content-Type' header
352 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
353 if ($_header_accept) {
354 $header_params->{'Accept'} = $_header_accept;
355 }
356 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
357  
358 # path params
359 if ( exists $args{'user_id'}) {
360 my $_base_variable = "{" . "user_id" . "}";
361 my $_base_value = $self->{api_client}->to_path_value($args{'user_id'});
362 $_resource_path =~ s/$_base_variable/$_base_value/g;
363 }
364  
365 my $_body_data;
366 # authentication setting, if any
367 my $auth_settings = [qw(token )];
368  
369 # make the API Call
370 my $response = $self->{api_client}->call_api($_resource_path, $_method,
371 $query_params, $form_params,
372 $header_params, $_body_data, $auth_settings);
373 if (!$response) {
374 return;
375 }
376 my $_response_object = $self->{api_client}->deserialize('UserResponse', $response);
377 return $_response_object;
378 }
379  
380 #
381 # request_password_reset
382 #
383 # Request a password reset
384 #
385 # @param string $user_login The login associated with the user (typically, an email address). (required)
386 {
387 my $params = {
388 'user_login' => {
389 data_type => 'string',
390 description => 'The login associated with the user (typically, an email address).',
391 required => '1',
392 },
393 };
394 __PACKAGE__->method_documentation->{ 'request_password_reset' } = {
395 summary => 'Request a password reset',
396 params => $params,
397 returns => 'InlineResponse200',
398 };
399 }
400 # @return InlineResponse200
401 #
402 sub request_password_reset {
403 my ($self, %args) = @_;
404  
405 # verify the required parameter 'user_login' is set
406 unless (exists $args{'user_login'}) {
407 croak("Missing the required parameter 'user_login' when calling request_password_reset");
408 }
409  
410 # parse inputs
411 my $_resource_path = '/user/{user_login}/password/request_reset';
412  
413 my $_method = 'POST';
414 my $query_params = {};
415 my $header_params = {};
416 my $form_params = {};
417  
418 # 'Accept' and 'Content-Type' header
419 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
420 if ($_header_accept) {
421 $header_params->{'Accept'} = $_header_accept;
422 }
423 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
424  
425 # path params
426 if ( exists $args{'user_login'}) {
427 my $_base_variable = "{" . "user_login" . "}";
428 my $_base_value = $self->{api_client}->to_path_value($args{'user_login'});
429 $_resource_path =~ s/$_base_variable/$_base_value/g;
430 }
431  
432 my $_body_data;
433 # authentication setting, if any
434 my $auth_settings = [qw(token )];
435  
436 # make the API Call
437 my $response = $self->{api_client}->call_api($_resource_path, $_method,
438 $query_params, $form_params,
439 $header_params, $_body_data, $auth_settings);
440 if (!$response) {
441 return;
442 }
443 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
444 return $_response_object;
445 }
446  
447 #
448 # update_user
449 #
450 # Update a user
451 #
452 # @param string $user_id Alphanumeric string identifying the user. (required)
453 # @param string $login (optional)
454 # @param string $name The real life name of the user. (optional)
455 # @param boolean $limit_services Indicates that the user has limited access to the customer's services. (optional)
456 # @param boolean $locked Indicates whether the is account is locked for editing or not. (optional)
457 # @param boolean $require_new_password Indicates if a new password is required at next login. (optional)
458 # @param RoleUser $role (optional)
459 # @param ARRAY[string] $roles A list of role IDs assigned to the user. (optional)
460 # @param boolean $two_factor_auth_enabled Indicates if 2FA is enabled on the user. (optional)
461 # @param boolean $two_factor_setup_required Indicates if 2FA is required by the user's customer account. (optional)
462 {
463 my $params = {
464 'user_id' => {
465 data_type => 'string',
466 description => 'Alphanumeric string identifying the user.',
467 required => '1',
468 },
469 'login' => {
470 data_type => 'string',
471 description => '',
472 required => '0',
473 },
474 'name' => {
475 data_type => 'string',
476 description => 'The real life name of the user.',
477 required => '0',
478 },
479 'limit_services' => {
480 data_type => 'boolean',
481 description => 'Indicates that the user has limited access to the customer's services.',
482 required => '0',
483 },
484 'locked' => {
485 data_type => 'boolean',
486 description => 'Indicates whether the is account is locked for editing or not.',
487 required => '0',
488 },
489 'require_new_password' => {
490 data_type => 'boolean',
491 description => 'Indicates if a new password is required at next login.',
492 required => '0',
493 },
494 'role' => {
495 data_type => 'RoleUser',
496 description => '',
497 required => '0',
498 },
499 'roles' => {
500 data_type => 'ARRAY[string]',
501 description => 'A list of role IDs assigned to the user.',
502 required => '0',
503 },
504 'two_factor_auth_enabled' => {
505 data_type => 'boolean',
506 description => 'Indicates if 2FA is enabled on the user.',
507 required => '0',
508 },
509 'two_factor_setup_required' => {
510 data_type => 'boolean',
511 description => 'Indicates if 2FA is required by the user's customer account.',
512 required => '0',
513 },
514 };
515 __PACKAGE__->method_documentation->{ 'update_user' } = {
516 summary => 'Update a user',
517 params => $params,
518 returns => 'UserResponse',
519 };
520 }
521 # @return UserResponse
522 #
523 sub update_user {
524 my ($self, %args) = @_;
525  
526 # verify the required parameter 'user_id' is set
527 unless (exists $args{'user_id'}) {
528 croak("Missing the required parameter 'user_id' when calling update_user");
529 }
530  
531 # parse inputs
532 my $_resource_path = '/user/{user_id}';
533  
534 my $_method = 'PUT';
535 my $query_params = {};
536 my $header_params = {};
537 my $form_params = {};
538  
539 # 'Accept' and 'Content-Type' header
540 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
541 if ($_header_accept) {
542 $header_params->{'Accept'} = $_header_accept;
543 }
544 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
545  
546 # path params
547 if ( exists $args{'user_id'}) {
548 my $_base_variable = "{" . "user_id" . "}";
549 my $_base_value = $self->{api_client}->to_path_value($args{'user_id'});
550 $_resource_path =~ s/$_base_variable/$_base_value/g;
551 }
552  
553 # form params
554 if ( exists $args{'login'} ) {
555 $form_params->{'login'} = $self->{api_client}->to_form_value($args{'login'});
556 }
557  
558 # form params
559 if ( exists $args{'name'} ) {
560 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
561 }
562  
563 # form params
564 if ( exists $args{'limit_services'} ) {
565 $form_params->{'limit_services'} = $self->{api_client}->to_form_value($args{'limit_services'});
566 }
567  
568 # form params
569 if ( exists $args{'locked'} ) {
570 $form_params->{'locked'} = $self->{api_client}->to_form_value($args{'locked'});
571 }
572  
573 # form params
574 if ( exists $args{'require_new_password'} ) {
575 $form_params->{'require_new_password'} = $self->{api_client}->to_form_value($args{'require_new_password'});
576 }
577  
578 # form params
579 if ( exists $args{'role'} ) {
580 $form_params->{'role'} = $self->{api_client}->to_form_value($args{'role'});
581 }
582  
583 # form params
584 if ( exists $args{'roles'} ) {
585 $form_params->{'roles'} = $self->{api_client}->to_form_value($args{'roles'});
586 }
587  
588 # form params
589 if ( exists $args{'two_factor_auth_enabled'} ) {
590 $form_params->{'two_factor_auth_enabled'} = $self->{api_client}->to_form_value($args{'two_factor_auth_enabled'});
591 }
592  
593 # form params
594 if ( exists $args{'two_factor_setup_required'} ) {
595 $form_params->{'two_factor_setup_required'} = $self->{api_client}->to_form_value($args{'two_factor_setup_required'});
596 }
597  
598 my $_body_data;
599 # authentication setting, if any
600 my $auth_settings = [qw(token )];
601  
602 # make the API Call
603 my $response = $self->{api_client}->call_api($_resource_path, $_method,
604 $query_params, $form_params,
605 $header_params, $_body_data, $auth_settings);
606 if (!$response) {
607 return;
608 }
609 my $_response_object = $self->{api_client}->deserialize('UserResponse', $response);
610 return $_response_object;
611 }
612  
613 #
614 # update_user_password
615 #
616 # Update the user's password
617 #
618 # @param string $old_password The user's current password. (optional)
619 # @param string $new_password The user's new password. (optional)
620 {
621 my $params = {
622 'old_password' => {
623 data_type => 'string',
624 description => 'The user's current password.',
625 required => '0',
626 },
627 'new_password' => {
628 data_type => 'string',
629 description => 'The user's new password.',
630 required => '0',
631 },
632 };
633 __PACKAGE__->method_documentation->{ 'update_user_password' } = {
634 summary => 'Update the user's password',
635 params => $params,
636 returns => 'UserResponse',
637 };
638 }
639 # @return UserResponse
640 #
641 sub update_user_password {
642 my ($self, %args) = @_;
643  
644 # parse inputs
645 my $_resource_path = '/current_user/password';
646  
647 my $_method = 'POST';
648 my $query_params = {};
649 my $header_params = {};
650 my $form_params = {};
651  
652 # 'Accept' and 'Content-Type' header
653 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
654 if ($_header_accept) {
655 $header_params->{'Accept'} = $_header_accept;
656 }
657 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
658  
659 # form params
660 if ( exists $args{'old_password'} ) {
661 $form_params->{'old_password'} = $self->{api_client}->to_form_value($args{'old_password'});
662 }
663  
664 # form params
665 if ( exists $args{'new_password'} ) {
666 $form_params->{'new_password'} = $self->{api_client}->to_form_value($args{'new_password'});
667 }
668  
669 my $_body_data;
670 # authentication setting, if any
671 my $auth_settings = [qw(session_password_change )];
672  
673 # make the API Call
674 my $response = $self->{api_client}->call_api($_resource_path, $_method,
675 $query_params, $form_params,
676 $header_params, $_body_data, $auth_settings);
677 if (!$response) {
678 return;
679 }
680 my $_response_object = $self->{api_client}->deserialize('UserResponse', $response);
681 return $_response_object;
682 }
683  
684 1;