Fastly/AiRuntimeControlUsageMetricsApi.pm untested

filter: Statementstmt 0.0% 0 / 102 Branchbran 0.0% 0 / 34 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 / 160 CC 18 SCAR 40.7
CC
18
Cov
0%
arc_get_usage_metrics
110.0
arc_export_usage_metrics
72.0
new
6.0
CRAP 58.8
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::AiRuntimeControlUsageMetricsApi;
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 # arc_export_usage_metrics
51 #
52 # Export usage metrics
53 #
54 # @param string $key Filter results to a specific virtual key ID. (optional)
55 # @param string $provider Filter results by AI provider connection ID. (optional)
56 # @param string $model Filter results by AI model identifier. (optional)
57 # @param DateTime $from The start of the time range, in RFC 3339 format. (optional)
58 # @param DateTime $to The end of the time range, in RFC 3339 format. Defaults to now. (optional)
59 {
60 my $params = {
61 'key' => {
62 data_type => 'string',
63 description => 'Filter results to a specific virtual key ID.',
64 required => '0',
65 },
66 'provider' => {
67 data_type => 'string',
68 description => 'Filter results by AI provider connection ID.',
69 required => '0',
70 },
71 'model' => {
72 data_type => 'string',
73 description => 'Filter results by AI model identifier.',
74 required => '0',
75 },
76 'from' => {
77 data_type => 'DateTime',
78 description => 'The start of the time range, in RFC 3339 format.',
79 required => '0',
80 },
81 'to' => {
82 data_type => 'DateTime',
83 description => 'The end of the time range, in RFC 3339 format. Defaults to now.',
84 required => '0',
85 },
86 };
87 __PACKAGE__->method_documentation->{ 'arc_export_usage_metrics' } = {
88 summary => 'Export usage metrics',
89 params => $params,
90 returns => 'ArcUsageMetricsResponse',
91 };
92 }
93 # @return ArcUsageMetricsResponse
94 #
95 sub arc_export_usage_metrics {
96 my ($self, %args) = @_;
97  
98 # parse inputs
99 my $_resource_path = '/ai-runtime-control/v1/usage-metrics/export';
100  
101 my $_method = 'GET';
102 my $query_params = {};
103 my $header_params = {};
104 my $form_params = {};
105  
106 # 'Accept' and 'Content-Type' header
107 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'text/csv', 'application/problem+json');
108 if ($_header_accept) {
109 $header_params->{'Accept'} = $_header_accept;
110 }
111 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
112  
113 # query params
114 if ( exists $args{'key'}) {
115 $query_params->{'key'} = $self->{api_client}->to_query_value($args{'key'});
116 }
117  
118 # query params
119 if ( exists $args{'provider'}) {
120 $query_params->{'provider'} = $self->{api_client}->to_query_value($args{'provider'});
121 }
122  
123 # query params
124 if ( exists $args{'model'}) {
125 $query_params->{'model'} = $self->{api_client}->to_query_value($args{'model'});
126 }
127  
128 # query params
129 if ( exists $args{'from'}) {
130 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
131 }
132  
133 # query params
134 if ( exists $args{'to'}) {
135 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
136 }
137  
138 my $_body_data;
139 # authentication setting, if any
140 my $auth_settings = [qw(token )];
141  
142 # make the API Call
143 my $response = $self->{api_client}->call_api($_resource_path, $_method,
144 $query_params, $form_params,
145 $header_params, $_body_data, $auth_settings);
146 if (!$response) {
147 return;
148 }
149 my $_response_object = $self->{api_client}->deserialize('ArcUsageMetricsResponse', $response);
150 return $_response_object;
151 }
152  
153 #
154 # arc_get_usage_metrics
155 #
156 # Get usage metrics
157 #
158 # @param string $key Filter results to a specific virtual key ID. (optional)
159 # @param string $provider Filter results by AI provider connection ID. (optional)
160 # @param string $model Filter results by AI model identifier. (optional)
161 # @param DateTime $from The start of the time range, in RFC 3339 format. (optional)
162 # @param DateTime $to The end of the time range, in RFC 3339 format. Defaults to now. (optional)
163 # @param string $granularity The time granularity to aggregate usage by. (optional, default to 'daily')
164 # @param string $sort Sort field. Prefix with `-` for descending order (e.g., `sort=-date`). (optional, default to 'date')
165 {
166 my $params = {
167 'key' => {
168 data_type => 'string',
169 description => 'Filter results to a specific virtual key ID.',
170 required => '0',
171 },
172 'provider' => {
173 data_type => 'string',
174 description => 'Filter results by AI provider connection ID.',
175 required => '0',
176 },
177 'model' => {
178 data_type => 'string',
179 description => 'Filter results by AI model identifier.',
180 required => '0',
181 },
182 'from' => {
183 data_type => 'DateTime',
184 description => 'The start of the time range, in RFC 3339 format.',
185 required => '0',
186 },
187 'to' => {
188 data_type => 'DateTime',
189 description => 'The end of the time range, in RFC 3339 format. Defaults to now.',
190 required => '0',
191 },
192 'granularity' => {
193 data_type => 'string',
194 description => 'The time granularity to aggregate usage by.',
195 required => '0',
196 },
197 'sort' => {
198 data_type => 'string',
199 description => 'Sort field. Prefix with `-` for descending order (e.g., `sort=-date`). ',
200 required => '0',
201 },
202 };
203 __PACKAGE__->method_documentation->{ 'arc_get_usage_metrics' } = {
204 summary => 'Get usage metrics',
205 params => $params,
206 returns => 'ArcUsageMetricsResponse',
207 };
208 }
209 # @return ArcUsageMetricsResponse
210 #
211 sub arc_get_usage_metrics {
212 my ($self, %args) = @_;
213  
214 # parse inputs
215 my $_resource_path = '/ai-runtime-control/v1/usage-metrics';
216  
217 my $_method = 'GET';
218 my $query_params = {};
219 my $header_params = {};
220 my $form_params = {};
221  
222 # 'Accept' and 'Content-Type' header
223 my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/problem+json');
224 if ($_header_accept) {
225 $header_params->{'Accept'} = $_header_accept;
226 }
227 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
228  
229 # query params
230 if ( exists $args{'key'}) {
231 $query_params->{'key'} = $self->{api_client}->to_query_value($args{'key'});
232 }
233  
234 # query params
235 if ( exists $args{'provider'}) {
236 $query_params->{'provider'} = $self->{api_client}->to_query_value($args{'provider'});
237 }
238  
239 # query params
240 if ( exists $args{'model'}) {
241 $query_params->{'model'} = $self->{api_client}->to_query_value($args{'model'});
242 }
243  
244 # query params
245 if ( exists $args{'from'}) {
246 $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'});
247 }
248  
249 # query params
250 if ( exists $args{'to'}) {
251 $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'});
252 }
253  
254 # query params
255 if ( exists $args{'granularity'}) {
256 $query_params->{'granularity'} = $self->{api_client}->to_query_value($args{'granularity'});
257 }
258  
259 # query params
260 if ( exists $args{'sort'}) {
261 $query_params->{'sort'} = $self->{api_client}->to_query_value($args{'sort'});
262 }
263  
264 my $_body_data;
265 # authentication setting, if any
266 my $auth_settings = [qw(token )];
267  
268 # make the API Call
269 my $response = $self->{api_client}->call_api($_resource_path, $_method,
270 $query_params, $form_params,
271 $header_params, $_body_data, $auth_settings);
272 if (!$response) {
273 return;
274 }
275 my $_response_object = $self->{api_client}->deserialize('ArcUsageMetricsResponse', $response);
276 return $_response_object;
277 }
278  
279 1;