Fastly/ServerApi.pm untested

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