Fastly/KvStoreItemApi.pm untested

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