Skip to main content

gproxy_protocol/wire/openai/codex/
analytics.rs

1//! Codex account analytics contracts. Source: samples/codex/codex-rs/
2//! codex-backend-openapi-models/src/models/analytics.rs (schema 8dad4dcab85a).
3//! Attribution, extensions, null amounts and numeric precision are retained.
4use crate::{Rest, WireRequest, WireResponse};
5use serde::{Deserialize, Serialize};
6use serde_json::Number;
7
8#[derive(
9    Debug,
10    Clone,
11    PartialEq,
12    Serialize,
13    Deserialize,
14    gproxy_protocol_macros::WireBuilder,
15    gproxy_protocol_macros::DeclaredFields,
16)]
17#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
18pub struct ActiveUsersSummary {
19    pub total_users: i64,
20    pub clients: Vec<ClientActiveUsersCount>,
21    pub models: Option<Vec<ModelActivitySummary>>,
22    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
23    pub rest: Rest,
24}
25
26#[derive(
27    Debug,
28    Clone,
29    PartialEq,
30    Serialize,
31    Deserialize,
32    gproxy_protocol_macros::WireBuilder,
33    gproxy_protocol_macros::DeclaredFields,
34)]
35#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
36pub struct ClientActiveUsersCount {
37    pub client_id: String,
38    pub users: i64,
39    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
40    pub rest: Rest,
41}
42
43#[derive(
44    Debug,
45    Clone,
46    PartialEq,
47    Serialize,
48    Deserialize,
49    gproxy_protocol_macros::WireBuilder,
50    gproxy_protocol_macros::DeclaredFields,
51)]
52#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
53pub struct ClientWorkspaceUsageCount {
54    pub client_id: String,
55    pub users: i64,
56    pub threads: i64,
57    pub turns: i64,
58    pub credits: Number,
59    pub cost_usd: Option<String>,
60    pub on_demand_credits: Option<Number>,
61    pub uncached_text_input_tokens: Option<i64>,
62    pub cached_text_input_tokens: Option<i64>,
63    pub text_output_tokens: Option<i64>,
64    pub text_total_tokens: Option<i64>,
65    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
66    pub rest: Rest,
67}
68
69#[derive(
70    Debug,
71    Clone,
72    PartialEq,
73    Serialize,
74    Deserialize,
75    gproxy_protocol_macros::WireBuilder,
76    gproxy_protocol_macros::DeclaredFields,
77)]
78#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
79pub struct ConsumptionUsageGroup {
80    pub dimensions: std::collections::BTreeMap<String, String>,
81    pub is_other: Option<bool>,
82    pub credits: Number,
83    pub on_demand_credits: Option<Number>,
84    pub uncached_text_input_tokens: Option<i64>,
85    pub cached_text_input_tokens: Option<i64>,
86    pub text_output_tokens: Option<i64>,
87    pub text_total_tokens: Option<i64>,
88    pub total_tokens: Option<i64>,
89    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
90    pub rest: Rest,
91}
92
93#[derive(
94    Debug,
95    Clone,
96    PartialEq,
97    Serialize,
98    Deserialize,
99    gproxy_protocol_macros::WireBuilder,
100    gproxy_protocol_macros::DeclaredFields,
101)]
102#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
103pub struct CreditUsageEventBySurface {
104    pub date: String,
105    pub product_surface: String,
106    pub credit_amount: Number,
107    pub usage_id: Option<String>,
108    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
109    pub rest: Rest,
110}
111
112#[derive(
113    Debug,
114    Clone,
115    PartialEq,
116    Serialize,
117    Deserialize,
118    gproxy_protocol_macros::WireBuilder,
119    gproxy_protocol_macros::DeclaredFields,
120)]
121#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
122pub struct CreditUsageEventsResponse {
123    pub data: Vec<CreditUsageEventBySurface>,
124    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
125    pub rest: Rest,
126}
127
128#[derive(
129    Debug,
130    Clone,
131    PartialEq,
132    Serialize,
133    Deserialize,
134    gproxy_protocol_macros::WireBuilder,
135    gproxy_protocol_macros::DeclaredFields,
136)]
137#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
138pub struct CurrentUserCreditUsageDatum {
139    pub date: String,
140    pub values: std::collections::BTreeMap<String, Number>,
141    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
142    pub rest: Rest,
143}
144
145#[derive(
146    Debug,
147    Clone,
148    PartialEq,
149    Serialize,
150    Deserialize,
151    gproxy_protocol_macros::WireBuilder,
152    gproxy_protocol_macros::DeclaredFields,
153)]
154#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
155pub struct CurrentUserCreditUsageResponse {
156    pub breakdown: String,
157    pub data: Vec<CurrentUserCreditUsageDatum>,
158    pub series: Vec<CurrentUserCreditUsageSeries>,
159    pub unit: Option<String>,
160    pub data_freshness_ts: Option<String>,
161    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
162    pub rest: Rest,
163}
164
165#[derive(
166    Debug,
167    Clone,
168    PartialEq,
169    Serialize,
170    Deserialize,
171    gproxy_protocol_macros::WireBuilder,
172    gproxy_protocol_macros::DeclaredFields,
173)]
174#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
175pub struct CurrentUserCreditUsageSeries {
176    pub key: String,
177    pub label: String,
178    pub total: Number,
179    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
180    pub rest: Rest,
181}
182
183#[derive(
184    Debug,
185    Clone,
186    PartialEq,
187    Serialize,
188    Deserialize,
189    gproxy_protocol_macros::WireBuilder,
190    gproxy_protocol_macros::DeclaredFields,
191)]
192#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
193pub struct DailyProductSurfaceUsage {
194    pub attribution: Option<Vec<PersonalUsageAttribution>>,
195    pub date: String,
196    pub product_surface_usage_values: std::collections::BTreeMap<String, Number>,
197    pub premium_usage_values: Option<ProductSurfacePremiumUsageValues>,
198    pub models: Option<Vec<ModelUsage>>,
199    pub groups: Option<Vec<ConsumptionUsageGroup>>,
200    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
201    pub rest: Rest,
202}
203
204#[derive(
205    Debug,
206    Clone,
207    PartialEq,
208    Serialize,
209    Deserialize,
210    gproxy_protocol_macros::WireBuilder,
211    gproxy_protocol_macros::DeclaredFields,
212)]
213#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
214pub struct DailyProductSurfaceUsageResponse {
215    pub data: Vec<DailyProductSurfaceUsage>,
216    pub units: Option<String>,
217    pub data_freshness_ts: Option<String>,
218    pub group_by: Option<String>,
219    pub breakdown_by: Option<Vec<String>>,
220    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
221    pub rest: Rest,
222}
223
224#[derive(
225    Debug,
226    Clone,
227    PartialEq,
228    Serialize,
229    Deserialize,
230    gproxy_protocol_macros::WireBuilder,
231    gproxy_protocol_macros::DeclaredFields,
232)]
233#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
234pub struct DailySkillUsageMetricsResponse {
235    pub data: Vec<DailySkillUsageOverview>,
236    pub data_freshness_ts: Option<String>,
237    pub group_by: Option<String>,
238    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
239    pub rest: Rest,
240}
241
242#[derive(
243    Debug,
244    Clone,
245    PartialEq,
246    Serialize,
247    Deserialize,
248    gproxy_protocol_macros::WireBuilder,
249    gproxy_protocol_macros::DeclaredFields,
250)]
251#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
252pub struct DailySkillUsageOverview {
253    pub date: String,
254    pub skill_usage_overviews: Vec<SkillUsageOverview>,
255    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
256    pub rest: Rest,
257}
258
259#[derive(
260    Debug,
261    Clone,
262    PartialEq,
263    Serialize,
264    Deserialize,
265    gproxy_protocol_macros::WireBuilder,
266    gproxy_protocol_macros::DeclaredFields,
267)]
268#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
269pub struct DailyWorkspaceUsageCount {
270    pub date: String,
271    pub totals: WorkspaceUsageCount,
272    pub clients: Vec<ClientWorkspaceUsageCount>,
273    pub models: Option<Vec<ModelUsage>>,
274    pub groups: Option<Vec<WorkspaceUsageGroup>>,
275    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
276    pub rest: Rest,
277}
278
279#[derive(
280    Debug,
281    Clone,
282    PartialEq,
283    Serialize,
284    Deserialize,
285    gproxy_protocol_macros::WireBuilder,
286    gproxy_protocol_macros::DeclaredFields,
287)]
288#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
289pub struct DailyWorkspaceUsageCountResponse {
290    pub data: Vec<DailyWorkspaceUsageCount>,
291    pub balance_unit: Option<String>,
292    pub active_users_summary: Option<ActiveUsersSummary>,
293    pub group_by: Option<String>,
294    pub breakdown_by: Option<Vec<String>>,
295    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
296    pub rest: Rest,
297}
298
299#[derive(
300    Debug,
301    Clone,
302    PartialEq,
303    Serialize,
304    Deserialize,
305    gproxy_protocol_macros::WireBuilder,
306    gproxy_protocol_macros::DeclaredFields,
307)]
308#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
309pub struct ModelActivitySummary {
310    pub model: String,
311    pub users: i64,
312    pub threads: i64,
313    pub turns: i64,
314    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
315    pub rest: Rest,
316}
317
318#[derive(
319    Debug,
320    Clone,
321    PartialEq,
322    Serialize,
323    Deserialize,
324    gproxy_protocol_macros::WireBuilder,
325    gproxy_protocol_macros::DeclaredFields,
326)]
327#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
328pub struct ModelUsage {
329    pub model: String,
330    pub speed: Option<String>,
331    pub credits: Number,
332    pub cost_usd: Option<String>,
333    pub users: Option<i64>,
334    pub threads: Option<i64>,
335    pub turns: Option<i64>,
336    pub on_demand_credits: Option<Number>,
337    pub uncached_text_input_tokens: Option<i64>,
338    pub cached_text_input_tokens: Option<i64>,
339    pub text_output_tokens: Option<i64>,
340    pub text_total_tokens: Option<i64>,
341    pub total_tokens: Option<i64>,
342    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
343    pub rest: Rest,
344}
345
346#[derive(
347    Debug,
348    Clone,
349    PartialEq,
350    Serialize,
351    Deserialize,
352    gproxy_protocol_macros::WireBuilder,
353    gproxy_protocol_macros::DeclaredFields,
354)]
355#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
356pub struct PersonalUsageAttribution {
357    pub thread_source: String,
358    pub turn_trigger: String,
359    pub model: String,
360    pub surface: String,
361    pub value: Number,
362    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
363    pub rest: Rest,
364}
365
366#[derive(
367    Debug,
368    Clone,
369    PartialEq,
370    Serialize,
371    Deserialize,
372    gproxy_protocol_macros::WireBuilder,
373    gproxy_protocol_macros::DeclaredFields,
374)]
375#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
376pub struct PluginUsageBucket {
377    pub date: String,
378    pub plugin_usage_overviews: Vec<PluginUsageOverview>,
379    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
380    pub rest: Rest,
381}
382
383#[derive(
384    Debug,
385    Clone,
386    PartialEq,
387    Serialize,
388    Deserialize,
389    gproxy_protocol_macros::WireBuilder,
390    gproxy_protocol_macros::DeclaredFields,
391)]
392#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
393pub struct PluginUsageMetricsResponse {
394    pub data: Vec<PluginUsageBucket>,
395    pub data_freshness_ts: Option<String>,
396    pub group_by: Option<String>,
397    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
398    pub rest: Rest,
399}
400
401#[derive(
402    Debug,
403    Clone,
404    PartialEq,
405    Serialize,
406    Deserialize,
407    gproxy_protocol_macros::WireBuilder,
408    gproxy_protocol_macros::DeclaredFields,
409)]
410#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
411pub struct PluginUsageOverview {
412    pub plugin_id: Option<String>,
413    pub plugin_name: String,
414    pub display_name: String,
415    pub marketplace: Option<String>,
416    pub invocation_counts: i64,
417    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
418    pub rest: Rest,
419}
420
421#[derive(
422    Debug,
423    Clone,
424    PartialEq,
425    Serialize,
426    Deserialize,
427    gproxy_protocol_macros::WireBuilder,
428    gproxy_protocol_macros::DeclaredFields,
429)]
430#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
431pub struct ProductSurfacePremiumUsageValues {
432    pub total_usage_credits: std::collections::BTreeMap<String, Number>,
433    pub credit_usage_credits: std::collections::BTreeMap<String, Number>,
434    pub uncached_text_input_tokens_by_surface: std::collections::BTreeMap<String, i64>,
435    pub cached_text_input_tokens_by_surface: std::collections::BTreeMap<String, i64>,
436    pub text_output_tokens_by_surface: std::collections::BTreeMap<String, i64>,
437    pub text_total_tokens_by_surface: std::collections::BTreeMap<String, i64>,
438    pub total_tokens_by_surface: Option<std::collections::BTreeMap<String, i64>>,
439    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
440    pub rest: Rest,
441}
442
443#[derive(
444    Debug,
445    Clone,
446    PartialEq,
447    Serialize,
448    Deserialize,
449    gproxy_protocol_macros::WireBuilder,
450    gproxy_protocol_macros::DeclaredFields,
451)]
452#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
453pub struct SkillUsageOverview {
454    pub skill_name: String,
455    pub display_name: String,
456    pub skill_ids: Vec<String>,
457    pub invocation_counts: i64,
458    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
459    pub rest: Rest,
460}
461
462#[derive(
463    Debug,
464    Clone,
465    PartialEq,
466    Serialize,
467    Deserialize,
468    gproxy_protocol_macros::WireBuilder,
469    gproxy_protocol_macros::DeclaredFields,
470)]
471#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
472pub struct WorkspaceUsageCount {
473    pub users: i64,
474    pub threads: i64,
475    pub turns: i64,
476    pub credits: Number,
477    pub cost_usd: Option<String>,
478    pub on_demand_credits: Option<Number>,
479    pub uncached_text_input_tokens: Option<i64>,
480    pub cached_text_input_tokens: Option<i64>,
481    pub text_output_tokens: Option<i64>,
482    pub text_total_tokens: Option<i64>,
483    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
484    pub rest: Rest,
485}
486
487#[derive(
488    Debug,
489    Clone,
490    PartialEq,
491    Serialize,
492    Deserialize,
493    gproxy_protocol_macros::WireBuilder,
494    gproxy_protocol_macros::DeclaredFields,
495)]
496#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
497pub struct WorkspaceUsageGroup {
498    pub dimensions: std::collections::BTreeMap<String, String>,
499    pub is_other: Option<bool>,
500    pub users: i64,
501    pub turns: i64,
502    pub cost_usd: Option<String>,
503    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
504    pub rest: Rest,
505}
506
507pub type DailyProductSurfaceUsageRequest = WireRequest<()>;
508pub type DailyProductSurfaceUsageWireResponse = WireResponse<DailyProductSurfaceUsageResponse>;
509pub type CreditUsageEventsRequest = WireRequest<()>;
510pub type CreditUsageEventsWireResponse = WireResponse<CreditUsageEventsResponse>;
511pub type CurrentUserCreditUsageRequest = WireRequest<()>;
512pub type CurrentUserCreditUsageWireResponse = WireResponse<CurrentUserCreditUsageResponse>;
513pub type DailyWorkspaceUsageCountRequest = WireRequest<()>;
514pub type DailyWorkspaceUsageCountWireResponse = WireResponse<DailyWorkspaceUsageCountResponse>;
515pub type PluginUsageMetricsRequest = WireRequest<()>;
516pub type PluginUsageMetricsWireResponse = WireResponse<PluginUsageMetricsResponse>;
517pub type DailySkillUsageMetricsRequest = WireRequest<()>;
518pub type DailySkillUsageMetricsWireResponse = WireResponse<DailySkillUsageMetricsResponse>;