Fastly/CustomerApi.pm untested

filter: Statementstmt 0.0% 0 / 215 Branchbran 0.0% 0 / 86 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 / 331 CC 44 SCAR 61.0
CC
44
Cov
0%
update_customer
870.0
delete_customer
30.0
get_customer
30.0
CRAP 443.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::CustomerApi;
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 # delete_customer
51 #
52 # Delete a customer
53 #
54 # @param string $customer_id Alphanumeric string identifying the customer. (required)
55 {
56 my $params = {
57 'customer_id' => {
58 data_type => 'string',
59 description => 'Alphanumeric string identifying the customer.',
60 required => '1',
61 },
62 };
63 __PACKAGE__->method_documentation->{ 'delete_customer' } = {
64 summary => 'Delete a customer',
65 params => $params,
66 returns => 'InlineResponse200',
67 };
68 }
69 # @return InlineResponse200
70 #
71 sub delete_customer {
72 my ($self, %args) = @_;
73  
74 # verify the required parameter 'customer_id' is set
75 unless (exists $args{'customer_id'}) {
76 croak("Missing the required parameter 'customer_id' when calling delete_customer");
77 }
78  
79 # parse inputs
80 my $_resource_path = '/customer/{customer_id}';
81  
82 my $_method = 'DELETE';
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');
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{'customer_id'}) {
96 my $_base_variable = "{" . "customer_id" . "}";
97 my $_base_value = $self->{api_client}->to_path_value($args{'customer_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('InlineResponse200', $response);
113 return $_response_object;
114 }
115  
116 #
117 # get_customer
118 #
119 # Get a customer
120 #
121 # @param string $customer_id Alphanumeric string identifying the customer. (required)
122 {
123 my $params = {
124 'customer_id' => {
125 data_type => 'string',
126 description => 'Alphanumeric string identifying the customer.',
127 required => '1',
128 },
129 };
130 __PACKAGE__->method_documentation->{ 'get_customer' } = {
131 summary => 'Get a customer',
132 params => $params,
133 returns => 'CustomerResponse',
134 };
135 }
136 # @return CustomerResponse
137 #
138 sub get_customer {
139 my ($self, %args) = @_;
140  
141 # verify the required parameter 'customer_id' is set
142 unless (exists $args{'customer_id'}) {
143 croak("Missing the required parameter 'customer_id' when calling get_customer");
144 }
145  
146 # parse inputs
147 my $_resource_path = '/customer/{customer_id}';
148  
149 my $_method = 'GET';
150 my $query_params = {};
151 my $header_params = {};
152 my $form_params = {};
153  
154 # 'Accept' and 'Content-Type' header
155 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
156 if ($_header_accept) {
157 $header_params->{'Accept'} = $_header_accept;
158 }
159 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
160  
161 # path params
162 if ( exists $args{'customer_id'}) {
163 my $_base_variable = "{" . "customer_id" . "}";
164 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
165 $_resource_path =~ s/$_base_variable/$_base_value/g;
166 }
167  
168 my $_body_data;
169 # authentication setting, if any
170 my $auth_settings = [qw(token )];
171  
172 # make the API Call
173 my $response = $self->{api_client}->call_api($_resource_path, $_method,
174 $query_params, $form_params,
175 $header_params, $_body_data, $auth_settings);
176 if (!$response) {
177 return;
178 }
179 my $_response_object = $self->{api_client}->deserialize('CustomerResponse', $response);
180 return $_response_object;
181 }
182  
183 #
184 # get_logged_in_customer
185 #
186 # Get the logged in customer
187 #
188 {
189 my $params = {
190 };
191 __PACKAGE__->method_documentation->{ 'get_logged_in_customer' } = {
192 summary => 'Get the logged in customer',
193 params => $params,
194 returns => 'CustomerResponse',
195 };
196 }
197 # @return CustomerResponse
198 #
199 sub get_logged_in_customer {
200 my ($self, %args) = @_;
201  
202 # parse inputs
203 my $_resource_path = '/current_customer';
204  
205 my $_method = 'GET';
206 my $query_params = {};
207 my $header_params = {};
208 my $form_params = {};
209  
210 # 'Accept' and 'Content-Type' header
211 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
212 if ($_header_accept) {
213 $header_params->{'Accept'} = $_header_accept;
214 }
215 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
216  
217 my $_body_data;
218 # authentication setting, if any
219 my $auth_settings = [qw(token )];
220  
221 # make the API Call
222 my $response = $self->{api_client}->call_api($_resource_path, $_method,
223 $query_params, $form_params,
224 $header_params, $_body_data, $auth_settings);
225 if (!$response) {
226 return;
227 }
228 my $_response_object = $self->{api_client}->deserialize('CustomerResponse', $response);
229 return $_response_object;
230 }
231  
232 #
233 # list_users
234 #
235 # List users
236 #
237 # @param string $customer_id Alphanumeric string identifying the customer. (required)
238 {
239 my $params = {
240 'customer_id' => {
241 data_type => 'string',
242 description => 'Alphanumeric string identifying the customer.',
243 required => '1',
244 },
245 };
246 __PACKAGE__->method_documentation->{ 'list_users' } = {
247 summary => 'List users',
248 params => $params,
249 returns => 'ARRAY[SchemasUserResponse]',
250 };
251 }
252 # @return ARRAY[SchemasUserResponse]
253 #
254 sub list_users {
255 my ($self, %args) = @_;
256  
257 # verify the required parameter 'customer_id' is set
258 unless (exists $args{'customer_id'}) {
259 croak("Missing the required parameter 'customer_id' when calling list_users");
260 }
261  
262 # parse inputs
263 my $_resource_path = '/customer/{customer_id}/users';
264  
265 my $_method = 'GET';
266 my $query_params = {};
267 my $header_params = {};
268 my $form_params = {};
269  
270 # 'Accept' and 'Content-Type' header
271 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
272 if ($_header_accept) {
273 $header_params->{'Accept'} = $_header_accept;
274 }
275 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
276  
277 # path params
278 if ( exists $args{'customer_id'}) {
279 my $_base_variable = "{" . "customer_id" . "}";
280 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
281 $_resource_path =~ s/$_base_variable/$_base_value/g;
282 }
283  
284 my $_body_data;
285 # authentication setting, if any
286 my $auth_settings = [qw(token )];
287  
288 # make the API Call
289 my $response = $self->{api_client}->call_api($_resource_path, $_method,
290 $query_params, $form_params,
291 $header_params, $_body_data, $auth_settings);
292 if (!$response) {
293 return;
294 }
295 my $_response_object = $self->{api_client}->deserialize('ARRAY[SchemasUserResponse]', $response);
296 return $_response_object;
297 }
298  
299 #
300 # update_customer
301 #
302 # Update a customer
303 #
304 # @param string $customer_id Alphanumeric string identifying the customer. (required)
305 # @param string $billing_contact_id The alphanumeric string representing the primary billing contact. (optional)
306 # @param string $billing_network_type Customer's current network revenue type. (optional)
307 # @param string $billing_ref Used for adding purchased orders to customer's account. (optional)
308 # @param boolean $can_configure_wordpress Whether this customer can view or edit wordpress. (optional)
309 # @param boolean $can_reset_passwords Whether this customer can reset passwords. (optional)
310 # @param boolean $can_upload_vcl Whether this customer can upload VCL. (optional)
311 # @param boolean $force_2fa Specifies whether 2FA is forced or not forced on the customer account. Logs out non-2FA users once 2FA is force enabled. (optional)
312 # @param boolean $force_sso Specifies whether SSO is forced or not forced on the customer account. (optional)
313 # @param boolean $has_account_panel Specifies whether the account has access or does not have access to the account panel. (optional)
314 # @param boolean $has_improved_events Specifies whether the account has access or does not have access to the improved events. (optional)
315 # @param boolean $has_improved_ssl_config Whether this customer can view or edit the SSL config. (optional)
316 # @param boolean $has_openstack_logging Specifies whether the account has enabled or not enabled openstack logging. (optional)
317 # @param boolean $has_pci Specifies whether the account can edit PCI for a service. (optional)
318 # @param boolean $has_pci_passwords Specifies whether PCI passwords are required for the account. (optional)
319 # @param string $ip_whitelist The range of IP addresses authorized to access the customer account. (optional)
320 # @param string $legal_contact_id The alphanumeric string identifying the account's legal contact. (optional)
321 # @param string $name The name of the customer, generally the company name. (optional)
322 # @param string $owner_id The alphanumeric string identifying the account owner. (optional)
323 # @param string $phone_number The phone number associated with the account. (optional)
324 # @param string $postal_address The postal address associated with the account. (optional)
325 # @param string $pricing_plan The pricing plan this customer is under. (optional)
326 # @param string $pricing_plan_id The alphanumeric string identifying the pricing plan. (optional)
327 # @param string $security_contact_id The alphanumeric string identifying the account's security contact. (optional)
328 # @param string $technical_contact_id The alphanumeric string identifying the account's technical contact. (optional)
329 {
330 my $params = {
331 'customer_id' => {
332 data_type => 'string',
333 description => 'Alphanumeric string identifying the customer.',
334 required => '1',
335 },
336 'billing_contact_id' => {
337 data_type => 'string',
338 description => 'The alphanumeric string representing the primary billing contact.',
339 required => '0',
340 },
341 'billing_network_type' => {
342 data_type => 'string',
343 description => 'Customer's current network revenue type.',
344 required => '0',
345 },
346 'billing_ref' => {
347 data_type => 'string',
348 description => 'Used for adding purchased orders to customer's account.',
349 required => '0',
350 },
351 'can_configure_wordpress' => {
352 data_type => 'boolean',
353 description => 'Whether this customer can view or edit wordpress.',
354 required => '0',
355 },
356 'can_reset_passwords' => {
357 data_type => 'boolean',
358 description => 'Whether this customer can reset passwords.',
359 required => '0',
360 },
361 'can_upload_vcl' => {
362 data_type => 'boolean',
363 description => 'Whether this customer can upload VCL.',
364 required => '0',
365 },
366 'force_2fa' => {
367 data_type => 'boolean',
368 description => 'Specifies whether 2FA is forced or not forced on the customer account. Logs out non-2FA users once 2FA is force enabled.',
369 required => '0',
370 },
371 'force_sso' => {
372 data_type => 'boolean',
373 description => 'Specifies whether SSO is forced or not forced on the customer account.',
374 required => '0',
375 },
376 'has_account_panel' => {
377 data_type => 'boolean',
378 description => 'Specifies whether the account has access or does not have access to the account panel.',
379 required => '0',
380 },
381 'has_improved_events' => {
382 data_type => 'boolean',
383 description => 'Specifies whether the account has access or does not have access to the improved events.',
384 required => '0',
385 },
386 'has_improved_ssl_config' => {
387 data_type => 'boolean',
388 description => 'Whether this customer can view or edit the SSL config.',
389 required => '0',
390 },
391 'has_openstack_logging' => {
392 data_type => 'boolean',
393 description => 'Specifies whether the account has enabled or not enabled openstack logging.',
394 required => '0',
395 },
396 'has_pci' => {
397 data_type => 'boolean',
398 description => 'Specifies whether the account can edit PCI for a service.',
399 required => '0',
400 },
401 'has_pci_passwords' => {
402 data_type => 'boolean',
403 description => 'Specifies whether PCI passwords are required for the account.',
404 required => '0',
405 },
406 'ip_whitelist' => {
407 data_type => 'string',
408 description => 'The range of IP addresses authorized to access the customer account.',
409 required => '0',
410 },
411 'legal_contact_id' => {
412 data_type => 'string',
413 description => 'The alphanumeric string identifying the account's legal contact.',
414 required => '0',
415 },
416 'name' => {
417 data_type => 'string',
418 description => 'The name of the customer, generally the company name.',
419 required => '0',
420 },
421 'owner_id' => {
422 data_type => 'string',
423 description => 'The alphanumeric string identifying the account owner.',
424 required => '0',
425 },
426 'phone_number' => {
427 data_type => 'string',
428 description => 'The phone number associated with the account.',
429 required => '0',
430 },
431 'postal_address' => {
432 data_type => 'string',
433 description => 'The postal address associated with the account.',
434 required => '0',
435 },
436 'pricing_plan' => {
437 data_type => 'string',
438 description => 'The pricing plan this customer is under.',
439 required => '0',
440 },
441 'pricing_plan_id' => {
442 data_type => 'string',
443 description => 'The alphanumeric string identifying the pricing plan.',
444 required => '0',
445 },
446 'security_contact_id' => {
447 data_type => 'string',
448 description => 'The alphanumeric string identifying the account's security contact.',
449 required => '0',
450 },
451 'technical_contact_id' => {
452 data_type => 'string',
453 description => 'The alphanumeric string identifying the account's technical contact.',
454 required => '0',
455 },
456 };
457 __PACKAGE__->method_documentation->{ 'update_customer' } = {
458 summary => 'Update a customer',
459 params => $params,
460 returns => 'CustomerResponse',
461 };
462 }
463 # @return CustomerResponse
464 #
465 sub update_customer {
466 my ($self, %args) = @_;
467  
468 # verify the required parameter 'customer_id' is set
469 unless (exists $args{'customer_id'}) {
470 croak("Missing the required parameter 'customer_id' when calling update_customer");
471 }
472  
473 # parse inputs
474 my $_resource_path = '/customer/{customer_id}';
475  
476 my $_method = 'PUT';
477 my $query_params = {};
478 my $header_params = {};
479 my $form_params = {};
480  
481 # 'Accept' and 'Content-Type' header
482 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
483 if ($_header_accept) {
484 $header_params->{'Accept'} = $_header_accept;
485 }
486 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
487  
488 # path params
489 if ( exists $args{'customer_id'}) {
490 my $_base_variable = "{" . "customer_id" . "}";
491 my $_base_value = $self->{api_client}->to_path_value($args{'customer_id'});
492 $_resource_path =~ s/$_base_variable/$_base_value/g;
493 }
494  
495 # form params
496 if ( exists $args{'billing_contact_id'} ) {
497 $form_params->{'billing_contact_id'} = $self->{api_client}->to_form_value($args{'billing_contact_id'});
498 }
499  
500 # form params
501 if ( exists $args{'billing_network_type'} ) {
502 $form_params->{'billing_network_type'} = $self->{api_client}->to_form_value($args{'billing_network_type'});
503 }
504  
505 # form params
506 if ( exists $args{'billing_ref'} ) {
507 $form_params->{'billing_ref'} = $self->{api_client}->to_form_value($args{'billing_ref'});
508 }
509  
510 # form params
511 if ( exists $args{'can_configure_wordpress'} ) {
512 $form_params->{'can_configure_wordpress'} = $self->{api_client}->to_form_value($args{'can_configure_wordpress'});
513 }
514  
515 # form params
516 if ( exists $args{'can_reset_passwords'} ) {
517 $form_params->{'can_reset_passwords'} = $self->{api_client}->to_form_value($args{'can_reset_passwords'});
518 }
519  
520 # form params
521 if ( exists $args{'can_upload_vcl'} ) {
522 $form_params->{'can_upload_vcl'} = $self->{api_client}->to_form_value($args{'can_upload_vcl'});
523 }
524  
525 # form params
526 if ( exists $args{'force_2fa'} ) {
527 $form_params->{'force_2fa'} = $self->{api_client}->to_form_value($args{'force_2fa'});
528 }
529  
530 # form params
531 if ( exists $args{'force_sso'} ) {
532 $form_params->{'force_sso'} = $self->{api_client}->to_form_value($args{'force_sso'});
533 }
534  
535 # form params
536 if ( exists $args{'has_account_panel'} ) {
537 $form_params->{'has_account_panel'} = $self->{api_client}->to_form_value($args{'has_account_panel'});
538 }
539  
540 # form params
541 if ( exists $args{'has_improved_events'} ) {
542 $form_params->{'has_improved_events'} = $self->{api_client}->to_form_value($args{'has_improved_events'});
543 }
544  
545 # form params
546 if ( exists $args{'has_improved_ssl_config'} ) {
547 $form_params->{'has_improved_ssl_config'} = $self->{api_client}->to_form_value($args{'has_improved_ssl_config'});
548 }
549  
550 # form params
551 if ( exists $args{'has_openstack_logging'} ) {
552 $form_params->{'has_openstack_logging'} = $self->{api_client}->to_form_value($args{'has_openstack_logging'});
553 }
554  
555 # form params
556 if ( exists $args{'has_pci'} ) {
557 $form_params->{'has_pci'} = $self->{api_client}->to_form_value($args{'has_pci'});
558 }
559  
560 # form params
561 if ( exists $args{'has_pci_passwords'} ) {
562 $form_params->{'has_pci_passwords'} = $self->{api_client}->to_form_value($args{'has_pci_passwords'});
563 }
564  
565 # form params
566 if ( exists $args{'ip_whitelist'} ) {
567 $form_params->{'ip_whitelist'} = $self->{api_client}->to_form_value($args{'ip_whitelist'});
568 }
569  
570 # form params
571 if ( exists $args{'legal_contact_id'} ) {
572 $form_params->{'legal_contact_id'} = $self->{api_client}->to_form_value($args{'legal_contact_id'});
573 }
574  
575 # form params
576 if ( exists $args{'name'} ) {
577 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
578 }
579  
580 # form params
581 if ( exists $args{'owner_id'} ) {
582 $form_params->{'owner_id'} = $self->{api_client}->to_form_value($args{'owner_id'});
583 }
584  
585 # form params
586 if ( exists $args{'phone_number'} ) {
587 $form_params->{'phone_number'} = $self->{api_client}->to_form_value($args{'phone_number'});
588 }
589  
590 # form params
591 if ( exists $args{'postal_address'} ) {
592 $form_params->{'postal_address'} = $self->{api_client}->to_form_value($args{'postal_address'});
593 }
594  
595 # form params
596 if ( exists $args{'pricing_plan'} ) {
597 $form_params->{'pricing_plan'} = $self->{api_client}->to_form_value($args{'pricing_plan'});
598 }
599  
600 # form params
601 if ( exists $args{'pricing_plan_id'} ) {
602 $form_params->{'pricing_plan_id'} = $self->{api_client}->to_form_value($args{'pricing_plan_id'});
603 }
604  
605 # form params
606 if ( exists $args{'security_contact_id'} ) {
607 $form_params->{'security_contact_id'} = $self->{api_client}->to_form_value($args{'security_contact_id'});
608 }
609  
610 # form params
611 if ( exists $args{'technical_contact_id'} ) {
612 $form_params->{'technical_contact_id'} = $self->{api_client}->to_form_value($args{'technical_contact_id'});
613 }
614  
615 my $_body_data;
616 # authentication setting, if any
617 my $auth_settings = [qw(token )];
618  
619 # make the API Call
620 my $response = $self->{api_client}->call_api($_resource_path, $_method,
621 $query_params, $form_params,
622 $header_params, $_body_data, $auth_settings);
623 if (!$response) {
624 return;
625 }
626 my $_response_object = $self->{api_client}->deserialize('CustomerResponse', $response);
627 return $_response_object;
628 }
629  
630 1;