Fastly/DictionaryApi.pm untested

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