modrinth_api/apis/
threads_api.rs

1/*
2 * Labrinth
3 *
4 * This documentation doesn't provide a way to test our API. In order to facilitate testing, we recommend the following tools:  - [cURL](https://curl.se/) (recommended, command-line) - [ReqBIN](https://reqbin.com/) (recommended, online) - [Postman](https://www.postman.com/downloads/) - [Insomnia](https://insomnia.rest/) - Your web browser, if you don't need to send headers or a request body  Once you have a working client, you can test that it works by making a `GET` request to `https://staging-api.modrinth.com/`:  ```json {   \"about\": \"Welcome traveler!\",   \"documentation\": \"https://docs.modrinth.com\",   \"name\": \"modrinth-labrinth\",   \"version\": \"2.7.0\" } ```  If you got a response similar to the one above, you can use the Modrinth API! When you want to go live using the production API, use `api.modrinth.com` instead of `staging-api.modrinth.com`.  ## Authentication This API has two options for authentication: personal access tokens and [OAuth2](https://en.wikipedia.org/wiki/OAuth). All tokens are tied to a Modrinth user and use the `Authorization` header of the request.  Example: ``` Authorization: mrp_RNtLRSPmGj2pd1v1ubi52nX7TJJM9sznrmwhAuj511oe4t1jAqAQ3D6Wc8Ic ```  You do not need a token for most requests. Generally speaking, only the following types of requests require a token: - those which create data (such as version creation) - those which modify data (such as editing a project) - those which access private data (such as draft projects, notifications, emails, and payout data)  Each request requiring authentication has a certain scope. For example, to view the email of the user being requested, the token must have the `USER_READ_EMAIL` scope. You can find the list of available scopes [on GitHub](https://github.com/modrinth/labrinth/blob/master/src/models/pats.rs#L15). Making a request with an invalid scope will return a 401 error.  Please note that certain scopes and requests cannot be completed with a personal access token or using OAuth. For example, deleting a user account can only be done through Modrinth's frontend.  ### OAuth2 Applications interacting with the authenticated API should create an OAuth2 application. You can do this in [the developer settings](https://modrinth.com/settings/applications).  Once you have created a client, use the following URL to have a user authorize your client: ``` https://modrinth.com/auth/authorize?client_id=<CLIENT_ID>&redirect_uri=<CALLBACK_URL>&scope=<SCOPE_ONE>+<SCOPE_TWO>+<SCOPE_THREE> ```  Then, use the following URL to get the token: ``` https://api.modrinth.com/_internal/oauth/token ```  This route will be changed in the future to move the `_internal` part to `v3`.  ### Personal access tokens Personal access tokens (PATs) can be generated in from [the user settings](https://modrinth.com/settings/account).  ### GitHub tokens For backwards compatibility purposes, some types of GitHub tokens also work for authenticating a user with Modrinth's API, granting all scopes. **We urge any application still using GitHub tokens to start using personal access tokens for security and reliability purposes.** GitHub tokens will cease to function to authenticate with Modrinth's API as soon as version 3 of the API is made generally available.  ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with the [W3C spec](https://www.w3.org/TR/cors/). This allows for cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.  ## Identifiers The majority of items you can interact with in the API have a unique eight-digit base62 ID. Projects, versions, users, threads, teams, and reports all use this same way of identifying themselves. Version files use the sha1 or sha512 file hashes as identifiers.  Each project and user has a friendlier way of identifying them; slugs and usernames, respectively. While unique IDs are constant, slugs and usernames can change at any moment. If you want to store something in the long term, it is recommended to use the unique ID.  ## Ratelimits The API has a ratelimit defined per IP. Limits and remaining amounts are given in the response headers. - `X-Ratelimit-Limit`: the maximum number of requests that can be made in a minute - `X-Ratelimit-Remaining`: the number of requests remaining in the current ratelimit window - `X-Ratelimit-Reset`: the time in seconds until the ratelimit window resets  Ratelimits are the same no matter whether you use a token or not. The ratelimit is currently 300 requests per minute. If you have a use case requiring a higher limit, please [contact us](mailto:admin@modrinth.com).  ## User Agents To access the Modrinth API, you **must** use provide a uniquely-identifying `User-Agent` header. Providing a user agent that only identifies your HTTP client library (such as \"okhttp/4.9.3\") increases the likelihood that we will block your traffic. It is recommended, but not required, to include contact information in your user agent. This allows us to contact you if we would like a change in your application's behavior without having to block your traffic. - Bad: `User-Agent: okhttp/4.9.3` - Good: `User-Agent: project_name` - Better: `User-Agent: github_username/project_name/1.56.0` - Best: `User-Agent: github_username/project_name/1.56.0 (launcher.com)` or `User-Agent: github_username/project_name/1.56.0 (contact@launcher.com)`  ## Versioning Modrinth follows a simple pattern for its API versioning. In the event of a breaking API change, the API version in the URL path is bumped, and migration steps will be published below.  When an API is no longer the current one, it will immediately be considered deprecated. No more support will be provided for API versions older than the current one. It will be kept for some time, but this amount of time is not certain.  We will exercise various tactics to get people to update their implementation of our API. One example is by adding something like `STOP USING THIS API` to various data returned by the API.  Once an API version is completely deprecated, it will permanently return a 410 error. Please ensure your application handles these 410 errors.  ### Migrations Inside the following spoiler, you will be able to find all changes between versions of the Modrinth API, accompanied by tips and a guide to migrate applications to newer versions.  Here, you can also find changes for [Minotaur](https://github.com/modrinth/minotaur), Modrinth's official Gradle plugin. Major versions of Minotaur directly correspond to major versions of the Modrinth API.  <details><summary>API v1 to API v2</summary>  These bullet points cover most changes in the v2 API, but please note that fields containing `mod` in most contexts have been shifted to `project`.  For example, in the search route, the field `mod_id` was renamed to `project_id`.  - The search route has been moved from `/api/v1/mod` to `/v2/search` - New project fields: `project_type` (may be `mod` or `modpack`), `moderation_message` (which has a `message` and `body`), `gallery` - New search facet: `project_type` - Alphabetical sort removed (it didn't work and is not possible due to limits in MeiliSearch) - New search fields: `project_type`, `gallery`   - The gallery field is an array of URLs to images that are part of the project's gallery - The gallery is a new feature which allows the user to upload images showcasing their mod to the CDN which will be displayed on their mod page - Internal change: Any project file uploaded to Modrinth is now validated to make sure it's a valid Minecraft mod, Modpack, etc.   - For example, a Forge 1.17 mod with a JAR not containing a mods.toml will not be allowed to be uploaded to Modrinth - In project creation, projects may not upload a mod with no versions to review, however they can be saved as a draft   - Similarly, for version creation, a version may not be uploaded without any files - Donation URLs have been enabled - New project status: `archived`. Projects with this status do not appear in search - Tags (such as categories, loaders) now have icons (SVGs) and specific project types attached - Dependencies have been wiped and replaced with a new system - Notifications now have a `type` field, such as `project_update`  Along with this, project subroutes (such as `/v2/project/{id}/version`) now allow the slug to be used as the ID. This is also the case with user routes.  </details><details><summary>Minotaur v1 to Minotaur v2</summary>  Minotaur 2.x introduced a few breaking changes to how your buildscript is formatted.  First, instead of registering your own `publishModrinth` task, Minotaur now automatically creates a `modrinth` task. As such, you can replace the `task publishModrinth(type: TaskModrinthUpload) {` line with just `modrinth {`.  To declare supported Minecraft versions and mod loaders, the `gameVersions` and `loaders` arrays must now be used. The syntax for these are pretty self-explanatory.  Instead of using `releaseType`, you must now use `versionType`. This was actually changed in v1.2.0, but very few buildscripts have moved on from v1.1.0.  Dependencies have been changed to a special DSL. Create a `dependencies` block within the `modrinth` block, and then use `scope.type(\"project/version\")`. For example, `required.project(\"fabric-api\")` adds a required project dependency on Fabric API.  You may now use the slug anywhere that a project ID was previously required.  </details> 
5 *
6 * The version of the OpenAPI document: v2.7.0/15cf3fc
7 * Contact: support@modrinth.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_thread_message`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteThreadMessageError {
22    Status401(models::AuthError),
23    Status404(),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`get_open_reports`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetOpenReportsError {
31    Status401(models::AuthError),
32    Status404(),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`get_report`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum GetReportError {
40    Status401(models::AuthError),
41    Status404(),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`get_reports`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetReportsError {
49    Status401(models::AuthError),
50    Status404(),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_thread`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetThreadError {
58    Status404(),
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`get_threads`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum GetThreadsError {
66    Status404(),
67    UnknownValue(serde_json::Value),
68}
69
70/// struct for typed errors of method [`modify_report`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum ModifyReportError {
74    Status400(models::InvalidInputError),
75    Status401(models::AuthError),
76    Status404(),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`send_thread_message`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum SendThreadMessageError {
84    Status400(models::InvalidInputError),
85    Status404(),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`submit_report`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum SubmitReportError {
93    Status400(models::InvalidInputError),
94    Status401(models::AuthError),
95    UnknownValue(serde_json::Value),
96}
97
98
99pub async fn delete_thread_message(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteThreadMessageError>> {
100    let local_var_configuration = configuration;
101
102    let local_var_client = &local_var_configuration.client;
103
104    let local_var_uri_str = format!("{}/message/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
105    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
106
107    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
108        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
109    }
110    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
111        let local_var_key = local_var_apikey.key.clone();
112        let local_var_value = match local_var_apikey.prefix {
113            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
114            None => local_var_key,
115        };
116        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
117    };
118
119    let local_var_req = local_var_req_builder.build()?;
120    let local_var_resp = local_var_client.execute(local_var_req).await?;
121
122    let local_var_status = local_var_resp.status();
123    let local_var_content = local_var_resp.text().await?;
124
125    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
126        Ok(())
127    } else {
128        let local_var_entity: Option<DeleteThreadMessageError> = serde_json::from_str(&local_var_content).ok();
129        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
130        Err(Error::ResponseError(local_var_error))
131    }
132}
133
134pub async fn get_open_reports(configuration: &configuration::Configuration, count: Option<i32>) -> Result<Vec<models::Report>, Error<GetOpenReportsError>> {
135    let local_var_configuration = configuration;
136
137    let local_var_client = &local_var_configuration.client;
138
139    let local_var_uri_str = format!("{}/report", local_var_configuration.base_path);
140    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
141
142    if let Some(ref local_var_str) = count {
143        local_var_req_builder = local_var_req_builder.query(&[("count", &local_var_str.to_string())]);
144    }
145    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
146        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
147    }
148    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
149        let local_var_key = local_var_apikey.key.clone();
150        let local_var_value = match local_var_apikey.prefix {
151            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
152            None => local_var_key,
153        };
154        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
155    };
156
157    let local_var_req = local_var_req_builder.build()?;
158    let local_var_resp = local_var_client.execute(local_var_req).await?;
159
160    let local_var_status = local_var_resp.status();
161    let local_var_content = local_var_resp.text().await?;
162
163    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
164        serde_json::from_str(&local_var_content).map_err(Error::from)
165    } else {
166        let local_var_entity: Option<GetOpenReportsError> = serde_json::from_str(&local_var_content).ok();
167        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
168        Err(Error::ResponseError(local_var_error))
169    }
170}
171
172pub async fn get_report(configuration: &configuration::Configuration, id: &str) -> Result<models::Report, Error<GetReportError>> {
173    let local_var_configuration = configuration;
174
175    let local_var_client = &local_var_configuration.client;
176
177    let local_var_uri_str = format!("{}/report/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
178    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
179
180    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
181        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
182    }
183    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
184        let local_var_key = local_var_apikey.key.clone();
185        let local_var_value = match local_var_apikey.prefix {
186            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
187            None => local_var_key,
188        };
189        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
190    };
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        serde_json::from_str(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<GetReportError> = serde_json::from_str(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207pub async fn get_reports(configuration: &configuration::Configuration, ids: &str) -> Result<Vec<models::Report>, Error<GetReportsError>> {
208    let local_var_configuration = configuration;
209
210    let local_var_client = &local_var_configuration.client;
211
212    let local_var_uri_str = format!("{}/reports", local_var_configuration.base_path);
213    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
214
215    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
216    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
217        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
218    }
219    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
220        let local_var_key = local_var_apikey.key.clone();
221        let local_var_value = match local_var_apikey.prefix {
222            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
223            None => local_var_key,
224        };
225        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
226    };
227
228    let local_var_req = local_var_req_builder.build()?;
229    let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        serde_json::from_str(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<GetReportsError> = serde_json::from_str(&local_var_content).ok();
238        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239        Err(Error::ResponseError(local_var_error))
240    }
241}
242
243pub async fn get_thread(configuration: &configuration::Configuration, id: &str) -> Result<models::Thread, Error<GetThreadError>> {
244    let local_var_configuration = configuration;
245
246    let local_var_client = &local_var_configuration.client;
247
248    let local_var_uri_str = format!("{}/thread/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
249    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
250
251    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
252        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
253    }
254    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
255        let local_var_key = local_var_apikey.key.clone();
256        let local_var_value = match local_var_apikey.prefix {
257            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
258            None => local_var_key,
259        };
260        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
261    };
262
263    let local_var_req = local_var_req_builder.build()?;
264    let local_var_resp = local_var_client.execute(local_var_req).await?;
265
266    let local_var_status = local_var_resp.status();
267    let local_var_content = local_var_resp.text().await?;
268
269    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
270        serde_json::from_str(&local_var_content).map_err(Error::from)
271    } else {
272        let local_var_entity: Option<GetThreadError> = serde_json::from_str(&local_var_content).ok();
273        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
274        Err(Error::ResponseError(local_var_error))
275    }
276}
277
278pub async fn get_threads(configuration: &configuration::Configuration, ids: &str) -> Result<Vec<models::Thread>, Error<GetThreadsError>> {
279    let local_var_configuration = configuration;
280
281    let local_var_client = &local_var_configuration.client;
282
283    let local_var_uri_str = format!("{}/threads", local_var_configuration.base_path);
284    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
285
286    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
287    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
288        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
289    }
290    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
291        let local_var_key = local_var_apikey.key.clone();
292        let local_var_value = match local_var_apikey.prefix {
293            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
294            None => local_var_key,
295        };
296        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
297    };
298
299    let local_var_req = local_var_req_builder.build()?;
300    let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302    let local_var_status = local_var_resp.status();
303    let local_var_content = local_var_resp.text().await?;
304
305    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
306        serde_json::from_str(&local_var_content).map_err(Error::from)
307    } else {
308        let local_var_entity: Option<GetThreadsError> = serde_json::from_str(&local_var_content).ok();
309        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
310        Err(Error::ResponseError(local_var_error))
311    }
312}
313
314pub async fn modify_report(configuration: &configuration::Configuration, id: &str, modify_report_request: Option<models::ModifyReportRequest>) -> Result<(), Error<ModifyReportError>> {
315    let local_var_configuration = configuration;
316
317    let local_var_client = &local_var_configuration.client;
318
319    let local_var_uri_str = format!("{}/report/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
320    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
321
322    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
323        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324    }
325    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
326        let local_var_key = local_var_apikey.key.clone();
327        let local_var_value = match local_var_apikey.prefix {
328            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
329            None => local_var_key,
330        };
331        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
332    };
333    local_var_req_builder = local_var_req_builder.json(&modify_report_request);
334
335    let local_var_req = local_var_req_builder.build()?;
336    let local_var_resp = local_var_client.execute(local_var_req).await?;
337
338    let local_var_status = local_var_resp.status();
339    let local_var_content = local_var_resp.text().await?;
340
341    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
342        Ok(())
343    } else {
344        let local_var_entity: Option<ModifyReportError> = serde_json::from_str(&local_var_content).ok();
345        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
346        Err(Error::ResponseError(local_var_error))
347    }
348}
349
350pub async fn send_thread_message(configuration: &configuration::Configuration, id: &str, thread_message_body: Option<models::ThreadMessageBody>) -> Result<models::Thread, Error<SendThreadMessageError>> {
351    let local_var_configuration = configuration;
352
353    let local_var_client = &local_var_configuration.client;
354
355    let local_var_uri_str = format!("{}/thread/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
356    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
357
358    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
359        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
360    }
361    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
362        let local_var_key = local_var_apikey.key.clone();
363        let local_var_value = match local_var_apikey.prefix {
364            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
365            None => local_var_key,
366        };
367        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
368    };
369    local_var_req_builder = local_var_req_builder.json(&thread_message_body);
370
371    let local_var_req = local_var_req_builder.build()?;
372    let local_var_resp = local_var_client.execute(local_var_req).await?;
373
374    let local_var_status = local_var_resp.status();
375    let local_var_content = local_var_resp.text().await?;
376
377    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
378        serde_json::from_str(&local_var_content).map_err(Error::from)
379    } else {
380        let local_var_entity: Option<SendThreadMessageError> = serde_json::from_str(&local_var_content).ok();
381        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
382        Err(Error::ResponseError(local_var_error))
383    }
384}
385
386/// Bring a project, user, or version to the attention of the moderators by reporting it.
387pub async fn submit_report(configuration: &configuration::Configuration, creatable_report: Option<models::CreatableReport>) -> Result<models::Report, Error<SubmitReportError>> {
388    let local_var_configuration = configuration;
389
390    let local_var_client = &local_var_configuration.client;
391
392    let local_var_uri_str = format!("{}/report", local_var_configuration.base_path);
393    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
394
395    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
396        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
397    }
398    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
399        let local_var_key = local_var_apikey.key.clone();
400        let local_var_value = match local_var_apikey.prefix {
401            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
402            None => local_var_key,
403        };
404        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
405    };
406    local_var_req_builder = local_var_req_builder.json(&creatable_report);
407
408    let local_var_req = local_var_req_builder.build()?;
409    let local_var_resp = local_var_client.execute(local_var_req).await?;
410
411    let local_var_status = local_var_resp.status();
412    let local_var_content = local_var_resp.text().await?;
413
414    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
415        serde_json::from_str(&local_var_content).map_err(Error::from)
416    } else {
417        let local_var_entity: Option<SubmitReportError> = serde_json::from_str(&local_var_content).ok();
418        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
419        Err(Error::ResponseError(local_var_error))
420    }
421}
422