Fastly/PackageApi.pm untested

filter: Statementstmt 0.0% 0 / 108 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 164 CC 17 SCAR 40.0
CC
17
Cov
0%
put_package
110.0
get_package
56.0
new
6.0
CRAP 54.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::PackageApi;
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 # get_package
51 #
52 # Get details of the service's Compute package.
53 #
54 # @param string $service_id Alphanumeric string identifying the service. (required)
55 # @param int $version_id Integer identifying a service version. (required)
56 {
57 my $params = {
58 'service_id' => {
59 data_type => 'string',
60 description => 'Alphanumeric string identifying the service.',
61 required => '1',
62 },
63 'version_id' => {
64 data_type => 'int',
65 description => 'Integer identifying a service version.',
66 required => '1',
67 },
68 };
69 __PACKAGE__->method_documentation->{ 'get_package' } = {
70 summary => 'Get details of the service's Compute package.',
71 params => $params,
72 returns => 'PackageResponse',
73 };
74 }
75 # @return PackageResponse
76 #
77 sub get_package {
78 my ($self, %args) = @_;
79  
80 # verify the required parameter 'service_id' is set
81 unless (exists $args{'service_id'}) {
82 croak("Missing the required parameter 'service_id' when calling get_package");
83 }
84  
85 # verify the required parameter 'version_id' is set
86 unless (exists $args{'version_id'}) {
87 croak("Missing the required parameter 'version_id' when calling get_package");
88 }
89  
90 # parse inputs
91 my $_resource_path = '/service/{service_id}/version/{version_id}/package';
92  
93 my $_method = 'GET';
94 my $query_params = {};
95 my $header_params = {};
96 my $form_params = {};
97  
98 # 'Accept' and 'Content-Type' header
99 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
100 if ($_header_accept) {
101 $header_params->{'Accept'} = $_header_accept;
102 }
103 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
104  
105 # path params
106 if ( exists $args{'service_id'}) {
107 my $_base_variable = "{" . "service_id" . "}";
108 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
109 $_resource_path =~ s/$_base_variable/$_base_value/g;
110 }
111  
112 # path params
113 if ( exists $args{'version_id'}) {
114 my $_base_variable = "{" . "version_id" . "}";
115 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
116 $_resource_path =~ s/$_base_variable/$_base_value/g;
117 }
118  
119 my $_body_data;
120 # authentication setting, if any
121 my $auth_settings = [qw(token )];
122  
123 # make the API Call
124 my $response = $self->{api_client}->call_api($_resource_path, $_method,
125 $query_params, $form_params,
126 $header_params, $_body_data, $auth_settings);
127 if (!$response) {
128 return;
129 }
130 my $_response_object = $self->{api_client}->deserialize('PackageResponse', $response);
131 return $_response_object;
132 }
133  
134 #
135 # put_package
136 #
137 # Upload a Compute package.
138 #
139 # @param string $service_id Alphanumeric string identifying the service. (required)
140 # @param int $version_id Integer identifying a service version. (required)
141 # @param string $expect We recommend using the Expect header because it may identify issues with the request based upon the headers alone instead of requiring you to wait until the entire binary package upload has completed. (optional)
142 # @param string $package The content of the Wasm binary package. (optional)
143 {
144 my $params = {
145 'service_id' => {
146 data_type => 'string',
147 description => 'Alphanumeric string identifying the service.',
148 required => '1',
149 },
150 'version_id' => {
151 data_type => 'int',
152 description => 'Integer identifying a service version.',
153 required => '1',
154 },
155 'expect' => {
156 data_type => 'string',
157 description => 'We recommend using the Expect header because it may identify issues with the request based upon the headers alone instead of requiring you to wait until the entire binary package upload has completed.',
158 required => '0',
159 },
160 'package' => {
161 data_type => 'string',
162 description => 'The content of the Wasm binary package.',
163 required => '0',
164 },
165 };
166 __PACKAGE__->method_documentation->{ 'put_package' } = {
167 summary => 'Upload a Compute package.',
168 params => $params,
169 returns => 'PackageResponse',
170 };
171 }
172 # @return PackageResponse
173 #
174 sub put_package {
175 my ($self, %args) = @_;
176  
177 # verify the required parameter 'service_id' is set
178 unless (exists $args{'service_id'}) {
179 croak("Missing the required parameter 'service_id' when calling put_package");
180 }
181  
182 # verify the required parameter 'version_id' is set
183 unless (exists $args{'version_id'}) {
184 croak("Missing the required parameter 'version_id' when calling put_package");
185 }
186  
187 # parse inputs
188 my $_resource_path = '/service/{service_id}/version/{version_id}/package';
189  
190 my $_method = 'PUT';
191 my $query_params = {};
192 my $header_params = {};
193 my $form_params = {};
194  
195 # 'Accept' and 'Content-Type' header
196 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
197 if ($_header_accept) {
198 $header_params->{'Accept'} = $_header_accept;
199 }
200 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('multipart/form-data');
201  
202 # header params
203 if ( exists $args{'expect'}) {
204 $header_params->{'expect'} = $self->{api_client}->to_header_value($args{'expect'});
205 }
206  
207 # path params
208 if ( exists $args{'service_id'}) {
209 my $_base_variable = "{" . "service_id" . "}";
210 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
211 $_resource_path =~ s/$_base_variable/$_base_value/g;
212 }
213  
214 # path params
215 if ( exists $args{'version_id'}) {
216 my $_base_variable = "{" . "version_id" . "}";
217 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
218 $_resource_path =~ s/$_base_variable/$_base_value/g;
219 }
220  
221 # form params
222 if ( exists $args{'package'} ) {
223 $form_params->{'package'} = [] unless defined $form_params->{'package'};
224 push @{$form_params->{'package'}}, $args{'package'};
225 }
226  
227 my $_body_data;
228 # authentication setting, if any
229 my $auth_settings = [qw(token )];
230  
231 # make the API Call
232 my $response = $self->{api_client}->call_api($_resource_path, $_method,
233 $query_params, $form_params,
234 $header_params, $_body_data, $auth_settings);
235 if (!$response) {
236 return;
237 }
238 my $_response_object = $self->{api_client}->deserialize('PackageResponse', $response);
239 return $_response_object;
240 }
241  
242 1;