Fastly/EventsApi.pm untested

filter: Statementstmt 0.0% 0 / 110 Branchbran 0.0% 0 / 40 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 / 174 CC 21 SCAR 49.5
CC
21
Cov
0%
list_events
272.0
get_event
30.0
new
6.0
CRAP 141.6
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::EventsApi;
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_event
51 #
52 # Get an event
53 #
54 # @param string $event_id Alphanumeric string identifying an event. (required)
55 {
56 my $params = {
57 'event_id' => {
58 data_type => 'string',
59 description => 'Alphanumeric string identifying an event.',
60 required => '1',
61 },
62 };
63 __PACKAGE__->method_documentation->{ 'get_event' } = {
64 summary => 'Get an event',
65 params => $params,
66 returns => 'EventResponse',
67 };
68 }
69 # @return EventResponse
70 #
71 sub get_event {
72 my ($self, %args) = @_;
73  
74 # verify the required parameter 'event_id' is set
75 unless (exists $args{'event_id'}) {
76 croak("Missing the required parameter 'event_id' when calling get_event");
77 }
78  
79 # parse inputs
80 my $_resource_path = '/events/{event_id}';
81  
82 my $_method = 'GET';
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/vnd.api+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{'event_id'}) {
96 my $_base_variable = "{" . "event_id" . "}";
97 my $_base_value = $self->{api_client}->to_path_value($args{'event_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('EventResponse', $response);
113 return $_response_object;
114 }
115  
116 #
117 # list_events
118 #
119 # List events
120 #
121 # @param string $filter[customer_id] Limit the results returned to a specific customer. (optional)
122 # @param string $filter[event_type] Limit the returned events to a specific `event_type`. (optional)
123 # @param string $filter[service_id] Limit the results returned to a specific service. (optional)
124 # @param string $filter[user_id] Limit the results returned to a specific user. (optional)
125 # @param string $filter[token_id] Limit the returned events to a specific token. (optional)
126 # @param string $filter[created_at] Limit the returned events to a specific time frame. Accepts sub-parameters: lt, lte, gt, gte (e.g., filter[created_at][gt]=2022-01-12). (optional)
127 # @param string $filter[created_at][lte] Return events on and before a date and time in ISO 8601 format. (optional)
128 # @param string $filter[created_at][lt] Return events before a date and time in ISO 8601 format. (optional)
129 # @param string $filter[created_at][gte] Return events on and after a date and time in ISO 8601 format. (optional)
130 # @param string $filter[created_at][gt] Return events after a date and time in ISO 8601 format. (optional)
131 # @param int $page[number] Current page. (optional)
132 # @param int $page[size] Number of records per page. (optional, default to 20)
133 # @param string $sort The order in which to list the results by creation date. (optional, default to 'created_at')
134 {
135 my $params = {
136 'filter[customer_id]' => {
137 data_type => 'string',
138 description => 'Limit the results returned to a specific customer.',
139 required => '0',
140 },
141 'filter[event_type]' => {
142 data_type => 'string',
143 description => 'Limit the returned events to a specific `event_type`.',
144 required => '0',
145 },
146 'filter[service_id]' => {
147 data_type => 'string',
148 description => 'Limit the results returned to a specific service.',
149 required => '0',
150 },
151 'filter[user_id]' => {
152 data_type => 'string',
153 description => 'Limit the results returned to a specific user.',
154 required => '0',
155 },
156 'filter[token_id]' => {
157 data_type => 'string',
158 description => 'Limit the returned events to a specific token.',
159 required => '0',
160 },
161 'filter[created_at]' => {
162 data_type => 'string',
163 description => 'Limit the returned events to a specific time frame. Accepts sub-parameters: lt, lte, gt, gte (e.g., filter[created_at][gt]=2022-01-12). ',
164 required => '0',
165 },
166 'filter[created_at][lte]' => {
167 data_type => 'string',
168 description => 'Return events on and before a date and time in ISO 8601 format. ',
169 required => '0',
170 },
171 'filter[created_at][lt]' => {
172 data_type => 'string',
173 description => 'Return events before a date and time in ISO 8601 format. ',
174 required => '0',
175 },
176 'filter[created_at][gte]' => {
177 data_type => 'string',
178 description => 'Return events on and after a date and time in ISO 8601 format. ',
179 required => '0',
180 },
181 'filter[created_at][gt]' => {
182 data_type => 'string',
183 description => 'Return events after a date and time in ISO 8601 format. ',
184 required => '0',
185 },
186 'page[number]' => {
187 data_type => 'int',
188 description => 'Current page.',
189 required => '0',
190 },
191 'page[size]' => {
192 data_type => 'int',
193 description => 'Number of records per page.',
194 required => '0',
195 },
196 'sort' => {
197 data_type => 'string',
198 description => 'The order in which to list the results by creation date.',
199 required => '0',
200 },
201 };
202 __PACKAGE__->method_documentation->{ 'list_events' } = {
203 summary => 'List events',
204 params => $params,
205 returns => 'EventsResponse',
206 };
207 }
208 # @return EventsResponse
209 #
210 sub list_events {
211 my ($self, %args) = @_;
212  
213 # parse inputs
214 my $_resource_path = '/events';
215  
216 my $_method = 'GET';
217 my $query_params = {};
218 my $header_params = {};
219 my $form_params = {};
220  
221 # 'Accept' and 'Content-Type' header
222 my $_header_accept = $self->{api_client}->select_header_accept('application/vnd.api+json');
223 if ($_header_accept) {
224 $header_params->{'Accept'} = $_header_accept;
225 }
226 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
227  
228 # query params
229 if ( exists $args{'filter[customer_id]'}) {
230 $query_params->{'filter[customer_id]'} = $self->{api_client}->to_query_value($args{'filter[customer_id]'});
231 }
232  
233 # query params
234 if ( exists $args{'filter[event_type]'}) {
235 $query_params->{'filter[event_type]'} = $self->{api_client}->to_query_value($args{'filter[event_type]'});
236 }
237  
238 # query params
239 if ( exists $args{'filter[service_id]'}) {
240 $query_params->{'filter[service_id]'} = $self->{api_client}->to_query_value($args{'filter[service_id]'});
241 }
242  
243 # query params
244 if ( exists $args{'filter[user_id]'}) {
245 $query_params->{'filter[user_id]'} = $self->{api_client}->to_query_value($args{'filter[user_id]'});
246 }
247  
248 # query params
249 if ( exists $args{'filter[token_id]'}) {
250 $query_params->{'filter[token_id]'} = $self->{api_client}->to_query_value($args{'filter[token_id]'});
251 }
252  
253 # query params
254 if ( exists $args{'filter[created_at]'}) {
255 $query_params->{'filter[created_at]'} = $self->{api_client}->to_query_value($args{'filter[created_at]'});
256 }
257  
258 # query params
259 if ( exists $args{'filter[created_at][lte]'}) {
260 $query_params->{'filter[created_at][lte]'} = $self->{api_client}->to_query_value($args{'filter[created_at][lte]'});
261 }
262  
263 # query params
264 if ( exists $args{'filter[created_at][lt]'}) {
265 $query_params->{'filter[created_at][lt]'} = $self->{api_client}->to_query_value($args{'filter[created_at][lt]'});
266 }
267  
268 # query params
269 if ( exists $args{'filter[created_at][gte]'}) {
270 $query_params->{'filter[created_at][gte]'} = $self->{api_client}->to_query_value($args{'filter[created_at][gte]'});
271 }
272  
273 # query params
274 if ( exists $args{'filter[created_at][gt]'}) {
275 $query_params->{'filter[created_at][gt]'} = $self->{api_client}->to_query_value($args{'filter[created_at][gt]'});
276 }
277  
278 # query params
279 if ( exists $args{'page[number]'}) {
280 $query_params->{'page[number]'} = $self->{api_client}->to_query_value($args{'page[number]'});
281 }
282  
283 # query params
284 if ( exists $args{'page[size]'}) {
285 $query_params->{'page[size]'} = $self->{api_client}->to_query_value($args{'page[size]'});
286 }
287  
288 # query params
289 if ( exists $args{'sort'}) {
290 $query_params->{'sort'} = $self->{api_client}->to_query_value($args{'sort'});
291 }
292  
293 my $_body_data;
294 # authentication setting, if any
295 my $auth_settings = [qw(token )];
296  
297 # make the API Call
298 my $response = $self->{api_client}->call_api($_resource_path, $_method,
299 $query_params, $form_params,
300 $header_params, $_body_data, $auth_settings);
301 if (!$response) {
302 return;
303 }
304 my $_response_object = $self->{api_client}->deserialize('EventsResponse', $response);
305 return $_response_object;
306 }
307  
308 1;