thunderstore_api/apis/
v1.rs

1////////////////////////////////////////////////////////////////////////////////
2// This Source Code Form is subject to the terms of the Mozilla Public         /
3// License, v. 2.0. If a copy of the MPL was not distributed with this         /
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
5////////////////////////////////////////////////////////////////////////////////
6
7/*
8 * Thunderstore API
9 *
10 * Schema is automatically generated and not completely accurate.
11 *
12 * The version of the OpenAPI document: v1
13 *
14 * Generated by: https://openapi-generator.tech
15 */
16
17use reqwest;
18
19use super::{configuration, Error};
20use crate::apis::ResponseContent;
21use crate::models::v1::package;
22
23/// struct for typed errors of method [`api_v1_bot_deprecate_mod_create`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum DeprecateModCreateError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`api_v1_current_user_info_list`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CurrentUserInfoListError {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`api_v1_package_list`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum PackageListError {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`api_v1_package_rate`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum PackageRateError {
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`api_v1_package_read`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum PackageReadError {
55    UnknownValue(serde_json::Value),
56}
57
58/// * Requires JWT authentication. * Only users with special permissions may use this action
59pub async fn deprecate_mod_create(
60    configuration: &configuration::Configuration,
61) -> Result<(), Error<DeprecateModCreateError>> {
62    let local_var_configuration = configuration;
63
64    let local_var_client = &local_var_configuration.client;
65
66    let local_var_uri_str = format!(
67        "{}/api/v1/bot/deprecate-mod/",
68        local_var_configuration.base_path
69    );
70    let mut local_var_req_builder =
71        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
72
73    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
74        local_var_req_builder =
75            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
76    }
77    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
78        local_var_req_builder = local_var_req_builder
79            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
80    };
81
82    let local_var_req = local_var_req_builder.build()?;
83    let local_var_resp = local_var_client.execute(local_var_req).await?;
84
85    let local_var_status = local_var_resp.status();
86    let local_var_content = local_var_resp.text().await?;
87
88    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
89        Ok(())
90    } else {
91        let local_var_entity: Option<DeprecateModCreateError> =
92            serde_json::from_str(&local_var_content).ok();
93        let local_var_error = ResponseContent {
94            status: local_var_status,
95            content: local_var_content,
96            entity: local_var_entity,
97        };
98        Err(Error::ResponseError(local_var_error))
99    }
100}
101
102/// Gets information about the current user, such as rated packages and permissions
103pub async fn current_user_info_list(
104    configuration: &configuration::Configuration,
105) -> Result<(), Error<CurrentUserInfoListError>> {
106    let local_var_configuration = configuration;
107
108    let local_var_client = &local_var_configuration.client;
109
110    let local_var_uri_str = format!(
111        "{}/api/v1/current-user/info/",
112        local_var_configuration.base_path
113    );
114    let mut local_var_req_builder =
115        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
116
117    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
118        local_var_req_builder =
119            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
120    }
121    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
122        local_var_req_builder = local_var_req_builder
123            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
124    };
125
126    let local_var_req = local_var_req_builder.build()?;
127    let local_var_resp = local_var_client.execute(local_var_req).await?;
128
129    let local_var_status = local_var_resp.status();
130    let local_var_content = local_var_resp.text().await?;
131
132    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
133        Ok(())
134    } else {
135        let local_var_entity: Option<CurrentUserInfoListError> =
136            serde_json::from_str(&local_var_content).ok();
137        let local_var_error = ResponseContent {
138            status: local_var_status,
139            content: local_var_content,
140            entity: local_var_entity,
141        };
142        Err(Error::ResponseError(local_var_error))
143    }
144}
145
146pub async fn package_list(
147    configuration: &configuration::Configuration,
148) -> Result<Vec<package::Listing>, Error<PackageListError>> {
149    let local_var_configuration = configuration;
150
151    let local_var_client = &local_var_configuration.client;
152
153    let local_var_uri_str = format!("{}/api/v1/package/", local_var_configuration.base_path);
154    let mut local_var_req_builder =
155        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
156
157    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158        local_var_req_builder =
159            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160    }
161    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
162        local_var_req_builder = local_var_req_builder
163            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
164    };
165
166    let local_var_req = local_var_req_builder.build()?;
167    let local_var_resp = local_var_client.execute(local_var_req).await?;
168
169    let local_var_status = local_var_resp.status();
170    let local_var_content = local_var_resp.text().await?;
171
172    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
173        serde_json::from_str(&local_var_content).map_err(Error::from)
174    } else {
175        let local_var_entity: Option<PackageListError> =
176            serde_json::from_str(&local_var_content).ok();
177        let local_var_error = ResponseContent {
178            status: local_var_status,
179            content: local_var_content,
180            entity: local_var_entity,
181        };
182        Err(Error::ResponseError(local_var_error))
183    }
184}
185
186pub async fn rate_package(
187    configuration: &configuration::Configuration,
188    uuid4: &str,
189    data: package::Listing,
190) -> Result<package::Listing, Error<PackageRateError>> {
191    let local_var_configuration = configuration;
192
193    let local_var_client = &local_var_configuration.client;
194
195    let local_var_uri_str = format!(
196        "{}/api/v1/package/{uuid4}/rate/",
197        local_var_configuration.base_path,
198        uuid4 = crate::apis::urlencode(uuid4)
199    );
200    let mut local_var_req_builder =
201        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
202
203    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204        local_var_req_builder =
205            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
208        local_var_req_builder = local_var_req_builder
209            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
210    };
211    local_var_req_builder = local_var_req_builder.json(&data);
212
213    let local_var_req = local_var_req_builder.build()?;
214    let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216    let local_var_status = local_var_resp.status();
217    let local_var_content = local_var_resp.text().await?;
218
219    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220        serde_json::from_str(&local_var_content).map_err(Error::from)
221    } else {
222        let local_var_entity: Option<PackageRateError> =
223            serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent {
225            status: local_var_status,
226            content: local_var_content,
227            entity: local_var_entity,
228        };
229        Err(Error::ResponseError(local_var_error))
230    }
231}
232
233pub async fn package_read(
234    configuration: &configuration::Configuration,
235    uuid4: &str,
236) -> Result<package::Listing, Error<PackageReadError>> {
237    let local_var_configuration = configuration;
238
239    let local_var_client = &local_var_configuration.client;
240
241    let local_var_uri_str = format!(
242        "{}/api/v1/package/{uuid4}/",
243        local_var_configuration.base_path,
244        uuid4 = crate::apis::urlencode(uuid4)
245    );
246    let mut local_var_req_builder =
247        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
248
249    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
250        local_var_req_builder =
251            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
252    }
253    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
254        local_var_req_builder = local_var_req_builder
255            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
256    };
257
258    let local_var_req = local_var_req_builder.build()?;
259    let local_var_resp = local_var_client.execute(local_var_req).await?;
260
261    let local_var_status = local_var_resp.status();
262    let local_var_content = local_var_resp.text().await?;
263
264    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
265        serde_json::from_str(&local_var_content).map_err(Error::from)
266    } else {
267        let local_var_entity: Option<PackageReadError> =
268            serde_json::from_str(&local_var_content).ok();
269        let local_var_error = ResponseContent {
270            status: local_var_status,
271            content: local_var_content,
272            entity: local_var_entity,
273        };
274        Err(Error::ResponseError(local_var_error))
275    }
276}
277
278/// struct for typed errors of method [`community_bot_deprecate_mod_create`]
279#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(untagged)]
281pub enum CommunityBotDeprecateModCreateError {
282    UnknownValue(serde_json::Value),
283}
284
285/// struct for typed errors of method [`community_current_user_info_list`]
286#[derive(Debug, Clone, Serialize, Deserialize)]
287#[serde(untagged)]
288pub enum CommunityCurrentUserInfoListError {
289    UnknownValue(serde_json::Value),
290}
291
292/// struct for typed errors of method [`community_package_list`]
293#[derive(Debug, Clone, Serialize, Deserialize)]
294#[serde(untagged)]
295pub enum CommunityPackageListError {
296    UnknownValue(serde_json::Value),
297}
298
299/// struct for typed errors of method [`community_package_rate`]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301#[serde(untagged)]
302pub enum CommunityPackageRateError {
303    UnknownValue(serde_json::Value),
304}
305
306/// struct for typed errors of method [`community_package_read`]
307#[derive(Debug, Clone, Serialize, Deserialize)]
308#[serde(untagged)]
309pub enum CommunityPackageReadError {
310    UnknownValue(serde_json::Value),
311}
312
313/// * Requires JWT authentication. * Only users with special permissions may use this action
314pub async fn community_bot_deprecate_mod_create(
315    configuration: &configuration::Configuration,
316    community_identifier: &str,
317) -> Result<(), Error<CommunityBotDeprecateModCreateError>> {
318    let local_var_configuration = configuration;
319
320    let local_var_client = &local_var_configuration.client;
321
322    let local_var_uri_str = format!(
323        "{}/c/{community_identifier}/api/v1/bot/deprecate-mod/",
324        local_var_configuration.base_path,
325        community_identifier = crate::apis::urlencode(community_identifier)
326    );
327    let mut local_var_req_builder =
328        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
329
330    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
331        local_var_req_builder =
332            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
333    }
334    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
335        local_var_req_builder = local_var_req_builder
336            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
337    };
338
339    let local_var_req = local_var_req_builder.build()?;
340    let local_var_resp = local_var_client.execute(local_var_req).await?;
341
342    let local_var_status = local_var_resp.status();
343    let local_var_content = local_var_resp.text().await?;
344
345    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
346        Ok(())
347    } else {
348        let local_var_entity: Option<CommunityBotDeprecateModCreateError> =
349            serde_json::from_str(&local_var_content).ok();
350        let local_var_error = ResponseContent {
351            status: local_var_status,
352            content: local_var_content,
353            entity: local_var_entity,
354        };
355        Err(Error::ResponseError(local_var_error))
356    }
357}
358
359/// Gets information about the current user, such as rated packages and permissions
360pub async fn community_current_user_info_list(
361    configuration: &configuration::Configuration,
362    community_identifier: &str,
363) -> Result<(), Error<CommunityCurrentUserInfoListError>> {
364    let local_var_configuration = configuration;
365
366    let local_var_client = &local_var_configuration.client;
367
368    let local_var_uri_str = format!(
369        "{}/c/{community_identifier}/api/v1/current-user/info/",
370        local_var_configuration.base_path,
371        community_identifier = crate::apis::urlencode(community_identifier)
372    );
373    let mut local_var_req_builder =
374        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
375
376    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
377        local_var_req_builder =
378            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
379    }
380    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
381        local_var_req_builder = local_var_req_builder
382            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
383    };
384
385    let local_var_req = local_var_req_builder.build()?;
386    let local_var_resp = local_var_client.execute(local_var_req).await?;
387
388    let local_var_status = local_var_resp.status();
389    let local_var_content = local_var_resp.text().await?;
390
391    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
392        Ok(())
393    } else {
394        let local_var_entity: Option<CommunityCurrentUserInfoListError> =
395            serde_json::from_str(&local_var_content).ok();
396        let local_var_error = ResponseContent {
397            status: local_var_status,
398            content: local_var_content,
399            entity: local_var_entity,
400        };
401        Err(Error::ResponseError(local_var_error))
402    }
403}
404
405pub async fn community_package_list(
406    configuration: &configuration::Configuration,
407    community_identifier: &str,
408) -> Result<Vec<package::Listing>, Error<CommunityPackageListError>> {
409    let local_var_configuration = configuration;
410
411    let local_var_client = &local_var_configuration.client;
412
413    let local_var_uri_str = format!(
414        "{}/c/{community_identifier}/api/v1/package/",
415        local_var_configuration.base_path,
416        community_identifier = crate::apis::urlencode(community_identifier)
417    );
418    let mut local_var_req_builder =
419        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
420
421    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
422        local_var_req_builder =
423            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
424    }
425    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
426        local_var_req_builder = local_var_req_builder
427            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
428    };
429
430    let local_var_req = local_var_req_builder.build()?;
431    let local_var_resp = local_var_client.execute(local_var_req).await?;
432
433    let local_var_status = local_var_resp.status();
434    let local_var_content = local_var_resp.text().await?;
435
436    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
437        serde_json::from_str(&local_var_content).map_err(Error::from)
438    } else {
439        let local_var_entity: Option<CommunityPackageListError> =
440            serde_json::from_str(&local_var_content).ok();
441        let local_var_error = ResponseContent {
442            status: local_var_status,
443            content: local_var_content,
444            entity: local_var_entity,
445        };
446        Err(Error::ResponseError(local_var_error))
447    }
448}
449
450pub async fn community_package_rate(
451    configuration: &configuration::Configuration,
452    community_identifier: &str,
453    uuid4: &str,
454    data: package::Listing,
455) -> Result<package::Listing, Error<CommunityPackageRateError>> {
456    let local_var_configuration = configuration;
457
458    let local_var_client = &local_var_configuration.client;
459
460    let local_var_uri_str = format!(
461        "{}/c/{community_identifier}/api/v1/package/{uuid4}/rate/",
462        local_var_configuration.base_path,
463        community_identifier = crate::apis::urlencode(community_identifier),
464        uuid4 = crate::apis::urlencode(uuid4)
465    );
466    let mut local_var_req_builder =
467        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
468
469    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
470        local_var_req_builder =
471            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
472    }
473    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
474        local_var_req_builder = local_var_req_builder
475            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
476    };
477    local_var_req_builder = local_var_req_builder.json(&data);
478
479    let local_var_req = local_var_req_builder.build()?;
480    let local_var_resp = local_var_client.execute(local_var_req).await?;
481
482    let local_var_status = local_var_resp.status();
483    let local_var_content = local_var_resp.text().await?;
484
485    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
486        serde_json::from_str(&local_var_content).map_err(Error::from)
487    } else {
488        let local_var_entity: Option<CommunityPackageRateError> =
489            serde_json::from_str(&local_var_content).ok();
490        let local_var_error = ResponseContent {
491            status: local_var_status,
492            content: local_var_content,
493            entity: local_var_entity,
494        };
495        Err(Error::ResponseError(local_var_error))
496    }
497}
498
499pub async fn community_package_read(
500    configuration: &configuration::Configuration,
501    community_identifier: &str,
502    uuid4: &str,
503) -> Result<package::Listing, Error<CommunityPackageReadError>> {
504    let local_var_configuration = configuration;
505
506    let local_var_client = &local_var_configuration.client;
507
508    let local_var_uri_str = format!(
509        "{}/c/{community_identifier}/api/v1/package/{uuid4}/",
510        local_var_configuration.base_path,
511        community_identifier = crate::apis::urlencode(community_identifier),
512        uuid4 = crate::apis::urlencode(uuid4)
513    );
514    let mut local_var_req_builder =
515        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
516
517    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
518        local_var_req_builder =
519            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
520    }
521    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
522        local_var_req_builder = local_var_req_builder
523            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
524    };
525
526    let local_var_req = local_var_req_builder.build()?;
527    let local_var_resp = local_var_client.execute(local_var_req).await?;
528
529    let local_var_status = local_var_resp.status();
530    let local_var_content = local_var_resp.text().await?;
531
532    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
533        serde_json::from_str(&local_var_content).map_err(Error::from)
534    } else {
535        let local_var_entity: Option<CommunityPackageReadError> =
536            serde_json::from_str(&local_var_content).ok();
537        let local_var_error = ResponseContent {
538            status: local_var_status,
539            content: local_var_content,
540            entity: local_var_entity,
541        };
542        Err(Error::ResponseError(local_var_error))
543    }
544}