modrinth_api/apis/
projects_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 [`add_gallery_image`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddGalleryImageError {
22    Status400(models::InvalidInputError),
23    Status401(models::AuthError),
24    Status404(),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`change_project_icon`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum ChangeProjectIconError {
32    Status400(models::InvalidInputError),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`check_project_validity`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum CheckProjectValidityError {
40    Status404(),
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`create_project`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum CreateProjectError {
48    Status400(models::InvalidInputError),
49    Status401(models::AuthError),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`delete_gallery_image`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DeleteGalleryImageError {
57    Status400(models::InvalidInputError),
58    Status401(models::AuthError),
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`delete_project`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum DeleteProjectError {
66    Status400(models::InvalidInputError),
67    Status401(models::AuthError),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`delete_project_icon`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum DeleteProjectIconError {
75    Status400(models::InvalidInputError),
76    Status401(models::AuthError),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`follow_project`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum FollowProjectError {
84    Status400(models::InvalidInputError),
85    Status401(models::AuthError),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`get_dependencies`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetDependenciesError {
93    Status404(),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`get_project`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum GetProjectError {
101    Status404(),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`get_projects`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum GetProjectsError {
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`modify_gallery_image`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum ModifyGalleryImageError {
116    Status401(models::AuthError),
117    Status404(),
118    UnknownValue(serde_json::Value),
119}
120
121/// struct for typed errors of method [`modify_project`]
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum ModifyProjectError {
125    Status401(models::AuthError),
126    Status404(),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`patch_projects`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum PatchProjectsError {
134    Status400(models::InvalidInputError),
135    Status401(models::AuthError),
136    UnknownValue(serde_json::Value),
137}
138
139/// struct for typed errors of method [`random_projects`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum RandomProjectsError {
143    Status400(models::InvalidInputError),
144    UnknownValue(serde_json::Value),
145}
146
147/// struct for typed errors of method [`schedule_project`]
148#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum ScheduleProjectError {
151    Status400(models::InvalidInputError),
152    Status401(models::AuthError),
153    UnknownValue(serde_json::Value),
154}
155
156/// struct for typed errors of method [`search_projects`]
157#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum SearchProjectsError {
160    Status400(models::InvalidInputError),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`unfollow_project`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum UnfollowProjectError {
168    Status400(models::InvalidInputError),
169    Status401(models::AuthError),
170    UnknownValue(serde_json::Value),
171}
172
173
174/// Modrinth allows you to upload files of up to 5MiB to a project's gallery.
175pub async fn add_gallery_image(configuration: &configuration::Configuration, id_pipe_slug: &str, ext: &str, featured: bool, title: Option<&str>, description: Option<&str>, ordering: Option<i32>, body: Option<std::path::PathBuf>) -> Result<(), Error<AddGalleryImageError>> {
176    let local_var_configuration = configuration;
177
178    let local_var_client = &local_var_configuration.client;
179
180    let local_var_uri_str = format!("{}/project/{term_1}/gallery", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
181    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
182
183    local_var_req_builder = local_var_req_builder.query(&[("ext", &ext.to_string())]);
184    local_var_req_builder = local_var_req_builder.query(&[("featured", &featured.to_string())]);
185    if let Some(ref local_var_str) = title {
186        local_var_req_builder = local_var_req_builder.query(&[("title", &local_var_str.to_string())]);
187    }
188    if let Some(ref local_var_str) = description {
189        local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
190    }
191    if let Some(ref local_var_str) = ordering {
192        local_var_req_builder = local_var_req_builder.query(&[("ordering", &local_var_str.to_string())]);
193    }
194    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
195        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
196    }
197    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
198        let local_var_key = local_var_apikey.key.clone();
199        let local_var_value = match local_var_apikey.prefix {
200            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
201            None => local_var_key,
202        };
203        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
204    };
205    local_var_req_builder = local_var_req_builder.json(&body);
206
207    let local_var_req = local_var_req_builder.build()?;
208    let local_var_resp = local_var_client.execute(local_var_req).await?;
209
210    let local_var_status = local_var_resp.status();
211    let local_var_content = local_var_resp.text().await?;
212
213    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
214        Ok(())
215    } else {
216        let local_var_entity: Option<AddGalleryImageError> = serde_json::from_str(&local_var_content).ok();
217        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
218        Err(Error::ResponseError(local_var_error))
219    }
220}
221
222/// The new icon may be up to 256KiB in size.
223pub async fn change_project_icon(configuration: &configuration::Configuration, id_pipe_slug: &str, ext: &str, body: Option<std::path::PathBuf>) -> Result<(), Error<ChangeProjectIconError>> {
224    let local_var_configuration = configuration;
225
226    let local_var_client = &local_var_configuration.client;
227
228    let local_var_uri_str = format!("{}/project/{term_1}/icon", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
229    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
230
231    local_var_req_builder = local_var_req_builder.query(&[("ext", &ext.to_string())]);
232    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
233        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
234    }
235    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
236        let local_var_key = local_var_apikey.key.clone();
237        let local_var_value = match local_var_apikey.prefix {
238            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
239            None => local_var_key,
240        };
241        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
242    };
243    local_var_req_builder = local_var_req_builder.json(&body);
244
245    let local_var_req = local_var_req_builder.build()?;
246    let local_var_resp = local_var_client.execute(local_var_req).await?;
247
248    let local_var_status = local_var_resp.status();
249    let local_var_content = local_var_resp.text().await?;
250
251    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
252        Ok(())
253    } else {
254        let local_var_entity: Option<ChangeProjectIconError> = serde_json::from_str(&local_var_content).ok();
255        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
256        Err(Error::ResponseError(local_var_error))
257    }
258}
259
260pub async fn check_project_validity(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<models::ProjectIdentifier, Error<CheckProjectValidityError>> {
261    let local_var_configuration = configuration;
262
263    let local_var_client = &local_var_configuration.client;
264
265    let local_var_uri_str = format!("{}/project/{term_1}/check", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
266    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
267
268    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
269        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
270    }
271
272    let local_var_req = local_var_req_builder.build()?;
273    let local_var_resp = local_var_client.execute(local_var_req).await?;
274
275    let local_var_status = local_var_resp.status();
276    let local_var_content = local_var_resp.text().await?;
277
278    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
279        serde_json::from_str(&local_var_content).map_err(Error::from)
280    } else {
281        let local_var_entity: Option<CheckProjectValidityError> = serde_json::from_str(&local_var_content).ok();
282        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
283        Err(Error::ResponseError(local_var_error))
284    }
285}
286
287pub async fn create_project(configuration: &configuration::Configuration, data: models::CreatableProject, icon: Option<std::path::PathBuf>) -> Result<models::Project, Error<CreateProjectError>> {
288    let local_var_configuration = configuration;
289
290    let local_var_client = &local_var_configuration.client;
291
292    let local_var_uri_str = format!("{}/project", local_var_configuration.base_path);
293    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
294
295    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
296        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
297    }
298    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
299        let local_var_key = local_var_apikey.key.clone();
300        let local_var_value = match local_var_apikey.prefix {
301            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
302            None => local_var_key,
303        };
304        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
305    };
306    let mut local_var_form = reqwest::multipart::Form::new();
307    local_var_form = local_var_form.text("data", serde_json::to_string(&data)?);
308    // TODO: support file upload for 'icon' parameter
309    local_var_req_builder = local_var_req_builder.multipart(local_var_form);
310
311    let local_var_req = local_var_req_builder.build()?;
312    let local_var_resp = local_var_client.execute(local_var_req).await?;
313
314    let local_var_status = local_var_resp.status();
315    let local_var_content = local_var_resp.text().await?;
316
317    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
318        serde_json::from_str(&local_var_content).map_err(Error::from)
319    } else {
320        let local_var_entity: Option<CreateProjectError> = serde_json::from_str(&local_var_content).ok();
321        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
322        Err(Error::ResponseError(local_var_error))
323    }
324}
325
326pub async fn delete_gallery_image(configuration: &configuration::Configuration, id_pipe_slug: &str, url: &str) -> Result<(), Error<DeleteGalleryImageError>> {
327    let local_var_configuration = configuration;
328
329    let local_var_client = &local_var_configuration.client;
330
331    let local_var_uri_str = format!("{}/project/{term_1}/gallery", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
332    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
333
334    local_var_req_builder = local_var_req_builder.query(&[("url", &url.to_string())]);
335    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
336        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
337    }
338    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
339        let local_var_key = local_var_apikey.key.clone();
340        let local_var_value = match local_var_apikey.prefix {
341            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
342            None => local_var_key,
343        };
344        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
345    };
346
347    let local_var_req = local_var_req_builder.build()?;
348    let local_var_resp = local_var_client.execute(local_var_req).await?;
349
350    let local_var_status = local_var_resp.status();
351    let local_var_content = local_var_resp.text().await?;
352
353    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
354        Ok(())
355    } else {
356        let local_var_entity: Option<DeleteGalleryImageError> = serde_json::from_str(&local_var_content).ok();
357        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
358        Err(Error::ResponseError(local_var_error))
359    }
360}
361
362pub async fn delete_project(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<(), Error<DeleteProjectError>> {
363    let local_var_configuration = configuration;
364
365    let local_var_client = &local_var_configuration.client;
366
367    let local_var_uri_str = format!("{}/project/{term_1}", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
368    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
369
370    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
371        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
372    }
373    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
374        let local_var_key = local_var_apikey.key.clone();
375        let local_var_value = match local_var_apikey.prefix {
376            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
377            None => local_var_key,
378        };
379        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
380    };
381
382    let local_var_req = local_var_req_builder.build()?;
383    let local_var_resp = local_var_client.execute(local_var_req).await?;
384
385    let local_var_status = local_var_resp.status();
386    let local_var_content = local_var_resp.text().await?;
387
388    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
389        Ok(())
390    } else {
391        let local_var_entity: Option<DeleteProjectError> = serde_json::from_str(&local_var_content).ok();
392        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
393        Err(Error::ResponseError(local_var_error))
394    }
395}
396
397pub async fn delete_project_icon(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<(), Error<DeleteProjectIconError>> {
398    let local_var_configuration = configuration;
399
400    let local_var_client = &local_var_configuration.client;
401
402    let local_var_uri_str = format!("{}/project/{term_1}/icon", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
403    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
404
405    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
406        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
407    }
408    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
409        let local_var_key = local_var_apikey.key.clone();
410        let local_var_value = match local_var_apikey.prefix {
411            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
412            None => local_var_key,
413        };
414        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
415    };
416
417    let local_var_req = local_var_req_builder.build()?;
418    let local_var_resp = local_var_client.execute(local_var_req).await?;
419
420    let local_var_status = local_var_resp.status();
421    let local_var_content = local_var_resp.text().await?;
422
423    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
424        Ok(())
425    } else {
426        let local_var_entity: Option<DeleteProjectIconError> = serde_json::from_str(&local_var_content).ok();
427        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
428        Err(Error::ResponseError(local_var_error))
429    }
430}
431
432pub async fn follow_project(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<(), Error<FollowProjectError>> {
433    let local_var_configuration = configuration;
434
435    let local_var_client = &local_var_configuration.client;
436
437    let local_var_uri_str = format!("{}/project/{term_1}/follow", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
438    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
439
440    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
441        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
442    }
443    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
444        let local_var_key = local_var_apikey.key.clone();
445        let local_var_value = match local_var_apikey.prefix {
446            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
447            None => local_var_key,
448        };
449        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
450    };
451
452    let local_var_req = local_var_req_builder.build()?;
453    let local_var_resp = local_var_client.execute(local_var_req).await?;
454
455    let local_var_status = local_var_resp.status();
456    let local_var_content = local_var_resp.text().await?;
457
458    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
459        Ok(())
460    } else {
461        let local_var_entity: Option<FollowProjectError> = serde_json::from_str(&local_var_content).ok();
462        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
463        Err(Error::ResponseError(local_var_error))
464    }
465}
466
467pub async fn get_dependencies(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<models::ProjectDependencyList, Error<GetDependenciesError>> {
468    let local_var_configuration = configuration;
469
470    let local_var_client = &local_var_configuration.client;
471
472    let local_var_uri_str = format!("{}/project/{term_1}/dependencies", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
473    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
474
475    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
476        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
477    }
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<GetDependenciesError> = serde_json::from_str(&local_var_content).ok();
489        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
490        Err(Error::ResponseError(local_var_error))
491    }
492}
493
494pub async fn get_project(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<models::Project, Error<GetProjectError>> {
495    let local_var_configuration = configuration;
496
497    let local_var_client = &local_var_configuration.client;
498
499    let local_var_uri_str = format!("{}/project/{term_1}", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
500    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
501
502    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
503        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
504    }
505
506    let local_var_req = local_var_req_builder.build()?;
507    let local_var_resp = local_var_client.execute(local_var_req).await?;
508
509    let local_var_status = local_var_resp.status();
510    let local_var_content = local_var_resp.text().await?;
511
512    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
513        serde_json::from_str(&local_var_content).map_err(Error::from)
514    } else {
515        let local_var_entity: Option<GetProjectError> = serde_json::from_str(&local_var_content).ok();
516        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
517        Err(Error::ResponseError(local_var_error))
518    }
519}
520
521pub async fn get_projects(configuration: &configuration::Configuration, ids: &str) -> Result<Vec<models::Project>, Error<GetProjectsError>> {
522    let local_var_configuration = configuration;
523
524    let local_var_client = &local_var_configuration.client;
525
526    let local_var_uri_str = format!("{}/projects", local_var_configuration.base_path);
527    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
528
529    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
530    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
531        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
532    }
533
534    let local_var_req = local_var_req_builder.build()?;
535    let local_var_resp = local_var_client.execute(local_var_req).await?;
536
537    let local_var_status = local_var_resp.status();
538    let local_var_content = local_var_resp.text().await?;
539
540    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
541        serde_json::from_str(&local_var_content).map_err(Error::from)
542    } else {
543        let local_var_entity: Option<GetProjectsError> = serde_json::from_str(&local_var_content).ok();
544        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
545        Err(Error::ResponseError(local_var_error))
546    }
547}
548
549pub async fn modify_gallery_image(configuration: &configuration::Configuration, id_pipe_slug: &str, url: &str, featured: Option<bool>, title: Option<&str>, description: Option<&str>, ordering: Option<i32>) -> Result<(), Error<ModifyGalleryImageError>> {
550    let local_var_configuration = configuration;
551
552    let local_var_client = &local_var_configuration.client;
553
554    let local_var_uri_str = format!("{}/project/{term_1}/gallery", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
555    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
556
557    local_var_req_builder = local_var_req_builder.query(&[("url", &url.to_string())]);
558    if let Some(ref local_var_str) = featured {
559        local_var_req_builder = local_var_req_builder.query(&[("featured", &local_var_str.to_string())]);
560    }
561    if let Some(ref local_var_str) = title {
562        local_var_req_builder = local_var_req_builder.query(&[("title", &local_var_str.to_string())]);
563    }
564    if let Some(ref local_var_str) = description {
565        local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
566    }
567    if let Some(ref local_var_str) = ordering {
568        local_var_req_builder = local_var_req_builder.query(&[("ordering", &local_var_str.to_string())]);
569    }
570    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
571        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
572    }
573    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
574        let local_var_key = local_var_apikey.key.clone();
575        let local_var_value = match local_var_apikey.prefix {
576            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
577            None => local_var_key,
578        };
579        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
580    };
581
582    let local_var_req = local_var_req_builder.build()?;
583    let local_var_resp = local_var_client.execute(local_var_req).await?;
584
585    let local_var_status = local_var_resp.status();
586    let local_var_content = local_var_resp.text().await?;
587
588    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
589        Ok(())
590    } else {
591        let local_var_entity: Option<ModifyGalleryImageError> = serde_json::from_str(&local_var_content).ok();
592        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
593        Err(Error::ResponseError(local_var_error))
594    }
595}
596
597pub async fn modify_project(configuration: &configuration::Configuration, id_pipe_slug: &str, editable_project: Option<models::EditableProject>) -> Result<(), Error<ModifyProjectError>> {
598    let local_var_configuration = configuration;
599
600    let local_var_client = &local_var_configuration.client;
601
602    let local_var_uri_str = format!("{}/project/{term_1}", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
603    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
604
605    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
606        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
607    }
608    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
609        let local_var_key = local_var_apikey.key.clone();
610        let local_var_value = match local_var_apikey.prefix {
611            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
612            None => local_var_key,
613        };
614        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
615    };
616    local_var_req_builder = local_var_req_builder.json(&editable_project);
617
618    let local_var_req = local_var_req_builder.build()?;
619    let local_var_resp = local_var_client.execute(local_var_req).await?;
620
621    let local_var_status = local_var_resp.status();
622    let local_var_content = local_var_resp.text().await?;
623
624    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
625        Ok(())
626    } else {
627        let local_var_entity: Option<ModifyProjectError> = serde_json::from_str(&local_var_content).ok();
628        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
629        Err(Error::ResponseError(local_var_error))
630    }
631}
632
633pub async fn patch_projects(configuration: &configuration::Configuration, ids: &str, patch_projects_body: Option<models::PatchProjectsBody>) -> Result<(), Error<PatchProjectsError>> {
634    let local_var_configuration = configuration;
635
636    let local_var_client = &local_var_configuration.client;
637
638    let local_var_uri_str = format!("{}/projects", local_var_configuration.base_path);
639    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
640
641    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
642    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
643        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
644    }
645    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
646        let local_var_key = local_var_apikey.key.clone();
647        let local_var_value = match local_var_apikey.prefix {
648            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
649            None => local_var_key,
650        };
651        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
652    };
653    local_var_req_builder = local_var_req_builder.json(&patch_projects_body);
654
655    let local_var_req = local_var_req_builder.build()?;
656    let local_var_resp = local_var_client.execute(local_var_req).await?;
657
658    let local_var_status = local_var_resp.status();
659    let local_var_content = local_var_resp.text().await?;
660
661    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
662        Ok(())
663    } else {
664        let local_var_entity: Option<PatchProjectsError> = serde_json::from_str(&local_var_content).ok();
665        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
666        Err(Error::ResponseError(local_var_error))
667    }
668}
669
670pub async fn random_projects(configuration: &configuration::Configuration, count: i32) -> Result<Vec<models::Project>, Error<RandomProjectsError>> {
671    let local_var_configuration = configuration;
672
673    let local_var_client = &local_var_configuration.client;
674
675    let local_var_uri_str = format!("{}/projects_random", local_var_configuration.base_path);
676    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
677
678    local_var_req_builder = local_var_req_builder.query(&[("count", &count.to_string())]);
679    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
680        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
681    }
682
683    let local_var_req = local_var_req_builder.build()?;
684    let local_var_resp = local_var_client.execute(local_var_req).await?;
685
686    let local_var_status = local_var_resp.status();
687    let local_var_content = local_var_resp.text().await?;
688
689    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
690        serde_json::from_str(&local_var_content).map_err(Error::from)
691    } else {
692        let local_var_entity: Option<RandomProjectsError> = serde_json::from_str(&local_var_content).ok();
693        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
694        Err(Error::ResponseError(local_var_error))
695    }
696}
697
698pub async fn schedule_project(configuration: &configuration::Configuration, id_pipe_slug: &str, schedule: Option<models::Schedule>) -> Result<(), Error<ScheduleProjectError>> {
699    let local_var_configuration = configuration;
700
701    let local_var_client = &local_var_configuration.client;
702
703    let local_var_uri_str = format!("{}/project/{term_1}/schedule", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
704    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
705
706    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
707        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
708    }
709    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
710        let local_var_key = local_var_apikey.key.clone();
711        let local_var_value = match local_var_apikey.prefix {
712            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
713            None => local_var_key,
714        };
715        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
716    };
717    local_var_req_builder = local_var_req_builder.json(&schedule);
718
719    let local_var_req = local_var_req_builder.build()?;
720    let local_var_resp = local_var_client.execute(local_var_req).await?;
721
722    let local_var_status = local_var_resp.status();
723    let local_var_content = local_var_resp.text().await?;
724
725    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
726        Ok(())
727    } else {
728        let local_var_entity: Option<ScheduleProjectError> = serde_json::from_str(&local_var_content).ok();
729        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
730        Err(Error::ResponseError(local_var_error))
731    }
732}
733
734pub async fn search_projects(configuration: &configuration::Configuration, query: Option<&str>, facets: Option<&str>, index: Option<&str>, offset: Option<i32>, limit: Option<i32>) -> Result<models::SearchResults, Error<SearchProjectsError>> {
735    let local_var_configuration = configuration;
736
737    let local_var_client = &local_var_configuration.client;
738
739    let local_var_uri_str = format!("{}/search", local_var_configuration.base_path);
740    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
741
742    if let Some(ref local_var_str) = query {
743        local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
744    }
745    if let Some(ref local_var_str) = facets {
746        local_var_req_builder = local_var_req_builder.query(&[("facets", &local_var_str.to_string())]);
747    }
748    if let Some(ref local_var_str) = index {
749        local_var_req_builder = local_var_req_builder.query(&[("index", &local_var_str.to_string())]);
750    }
751    if let Some(ref local_var_str) = offset {
752        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
753    }
754    if let Some(ref local_var_str) = limit {
755        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
756    }
757    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
758        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
759    }
760
761    let local_var_req = local_var_req_builder.build()?;
762    let local_var_resp = local_var_client.execute(local_var_req).await?;
763
764    let local_var_status = local_var_resp.status();
765    let local_var_content = local_var_resp.text().await?;
766
767    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
768        serde_json::from_str(&local_var_content).map_err(Error::from)
769    } else {
770        let local_var_entity: Option<SearchProjectsError> = serde_json::from_str(&local_var_content).ok();
771        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
772        Err(Error::ResponseError(local_var_error))
773    }
774}
775
776pub async fn unfollow_project(configuration: &configuration::Configuration, id_pipe_slug: &str) -> Result<(), Error<UnfollowProjectError>> {
777    let local_var_configuration = configuration;
778
779    let local_var_client = &local_var_configuration.client;
780
781    let local_var_uri_str = format!("{}/project/{term_1}/follow", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
782    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
783
784    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
785        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
786    }
787    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
788        let local_var_key = local_var_apikey.key.clone();
789        let local_var_value = match local_var_apikey.prefix {
790            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
791            None => local_var_key,
792        };
793        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
794    };
795
796    let local_var_req = local_var_req_builder.build()?;
797    let local_var_resp = local_var_client.execute(local_var_req).await?;
798
799    let local_var_status = local_var_resp.status();
800    let local_var_content = local_var_resp.text().await?;
801
802    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
803        Ok(())
804    } else {
805        let local_var_entity: Option<UnfollowProjectError> = serde_json::from_str(&local_var_content).ok();
806        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
807        Err(Error::ResponseError(local_var_error))
808    }
809}
810