1#[cfg(feature = "rust")]
2use bon::Builder;
3#[cfg(feature = "node")]
4use napi_derive::napi;
5#[cfg(feature = "python")]
6use pyo3::pyclass;
7#[cfg(feature = "python")]
8use pyo3_stub_gen::derive::gen_stub_pyclass;
9use serde::{Deserialize, Serialize};
10
11#[cfg_attr(feature = "python", gen_stub_pyclass)]
13#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
14#[cfg_attr(feature = "node", napi(object))]
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct MethodRateLimiter {
17 pub id: String,
19 pub interval: String,
21 #[serde(default)]
23 pub methods: Vec<String>,
24 pub rate: i32,
26 pub status: String,
28 pub created: String,
30}
31
32#[cfg_attr(feature = "python", gen_stub_pyclass)]
34#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
35#[cfg_attr(feature = "node", napi(object))]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct GetMethodRateLimitsData {
38 #[serde(default)]
40 pub rate_limiters: Vec<MethodRateLimiter>,
41}
42
43#[cfg_attr(feature = "python", gen_stub_pyclass)]
45#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
46#[cfg_attr(feature = "node", napi(object))]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct GetMethodRateLimitsResponse {
49 pub data: Option<GetMethodRateLimitsData>,
51 pub error: Option<String>,
53}
54
55#[cfg_attr(feature = "python", gen_stub_pyclass)]
57#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
58#[cfg_attr(feature = "node", napi(object))]
59#[cfg_attr(feature = "rust", derive(Builder))]
60#[derive(Debug, Clone, Default, Serialize)]
61pub struct CreateMethodRateLimitRequest {
62 pub interval: String,
64 pub methods: Vec<String>,
66 pub rate: i32,
68}
69
70#[cfg_attr(feature = "python", gen_stub_pyclass)]
72#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
73#[cfg_attr(feature = "node", napi(object))]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct CreateMethodRateLimitResponse {
76 pub data: Option<MethodRateLimiter>,
78 pub error: Option<String>,
80}
81
82#[cfg_attr(feature = "python", gen_stub_pyclass)]
84#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
85#[cfg_attr(feature = "node", napi(object))]
86#[cfg_attr(feature = "rust", derive(Builder))]
87#[derive(Debug, Clone, Default, Serialize)]
88pub struct UpdateMethodRateLimitRequest {
89 #[serde(skip_serializing_if = "Option::is_none")]
91 pub methods: Option<Vec<String>>,
92 #[serde(skip_serializing_if = "Option::is_none")]
94 pub status: Option<String>,
95 #[serde(skip_serializing_if = "Option::is_none")]
97 pub rate: Option<i32>,
98}
99
100#[cfg_attr(feature = "python", gen_stub_pyclass)]
102#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
103#[cfg_attr(feature = "node", napi(object))]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105pub struct UpdateMethodRateLimitResponse {
106 pub data: Option<MethodRateLimiter>,
108 pub error: Option<String>,
110}
111
112#[cfg_attr(feature = "python", gen_stub_pyclass)]
114#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
115#[cfg_attr(feature = "node", napi(object))]
116#[cfg_attr(feature = "rust", derive(Builder))]
117#[derive(Debug, Clone, Default, Serialize)]
118pub struct RateLimitSettings {
119 #[serde(skip_serializing_if = "Option::is_none")]
121 pub rps: Option<i32>,
122 #[serde(skip_serializing_if = "Option::is_none")]
124 pub rpm: Option<i32>,
125 #[serde(skip_serializing_if = "Option::is_none")]
127 pub rpd: Option<i32>,
128}
129
130#[cfg_attr(feature = "python", gen_stub_pyclass)]
132#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
133#[cfg_attr(feature = "node", napi(object))]
134#[cfg_attr(feature = "rust", derive(Builder))]
135#[derive(Debug, Clone, Default, Serialize)]
136pub struct UpdateRateLimitsRequest {
137 pub rate_limits: RateLimitSettings,
139}
140
141#[cfg_attr(feature = "python", gen_stub_pyclass)]
145#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
146#[cfg_attr(feature = "node", napi(object))]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct RateLimitEntry {
149 pub bucket: String,
151 pub rate_limit: i32,
153 pub source: String,
155 #[serde(default)]
159 pub id: Option<String>,
160}
161
162#[cfg_attr(feature = "python", gen_stub_pyclass)]
164#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
165#[cfg_attr(feature = "node", napi(object))]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167pub struct GetRateLimitsData {
168 #[serde(default)]
170 pub rate_limits: Vec<RateLimitEntry>,
171}
172
173#[cfg_attr(feature = "python", gen_stub_pyclass)]
175#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
176#[cfg_attr(feature = "node", napi(object))]
177#[derive(Debug, Clone, Serialize, Deserialize)]
178pub struct GetRateLimitsResponse {
179 pub data: Option<GetRateLimitsData>,
181 pub error: Option<String>,
183}