modrinth_api/apis/
versions_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_files_to_version`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddFilesToVersionError {
22    Status401(models::AuthError),
23    Status404(),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`create_version`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum CreateVersionError {
31    Status400(models::InvalidInputError),
32    Status401(models::AuthError),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`delete_version`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum DeleteVersionError {
40    Status401(models::AuthError),
41    Status404(),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`get_project_versions`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetProjectVersionsError {
49    Status404(),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_version`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetVersionError {
57    Status404(),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_version_from_id_or_number`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetVersionFromIdOrNumberError {
65    Status404(),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`get_versions`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetVersionsError {
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`modify_version`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ModifyVersionError {
80    Status401(models::AuthError),
81    Status404(),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`schedule_version`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum ScheduleVersionError {
89    Status400(models::InvalidInputError),
90    Status401(models::AuthError),
91    UnknownValue(serde_json::Value),
92}
93
94
95/// Project files are attached. `.mrpack` and `.jar` files are accepted.
96pub async fn add_files_to_version(configuration: &configuration::Configuration, id: &str, data: Option<serde_json::Value>) -> Result<(), Error<AddFilesToVersionError>> {
97    let local_var_configuration = configuration;
98
99    let local_var_client = &local_var_configuration.client;
100
101    let local_var_uri_str = format!("{}/version/{id}/file", local_var_configuration.base_path, id=crate::apis::urlencode(id));
102    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
103
104    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106    }
107    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
108        let local_var_key = local_var_apikey.key.clone();
109        let local_var_value = match local_var_apikey.prefix {
110            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
111            None => local_var_key,
112        };
113        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
114    };
115    let mut local_var_form = reqwest::multipart::Form::new();
116    if let Some(local_var_param_value) = data {
117        local_var_form = local_var_form.text("data", local_var_param_value.to_string());
118    }
119    local_var_req_builder = local_var_req_builder.multipart(local_var_form);
120
121    let local_var_req = local_var_req_builder.build()?;
122    let local_var_resp = local_var_client.execute(local_var_req).await?;
123
124    let local_var_status = local_var_resp.status();
125    let local_var_content = local_var_resp.text().await?;
126
127    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128        Ok(())
129    } else {
130        let local_var_entity: Option<AddFilesToVersionError> = serde_json::from_str(&local_var_content).ok();
131        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
132        Err(Error::ResponseError(local_var_error))
133    }
134}
135
136/// This route creates a version on an existing project. There must be at least one file attached to each new version, unless the new version's status is `draft`. `.mrpack`, `.jar`, `.zip`, and `.litemod` files are accepted.  The request is a [multipart request](https://www.ietf.org/rfc/rfc2388.txt) with at least two form fields: one is `data`, which includes a JSON body with the version metadata as shown below, and at least one field containing an upload file.  You can name the file parts anything you would like, but you must list each of the parts' names in `file_parts`, and optionally, provide one to use as the primary file in `primary_file`. 
137pub async fn create_version(configuration: &configuration::Configuration, data: models::CreatableVersion) -> Result<models::Version, Error<CreateVersionError>> {
138    let local_var_configuration = configuration;
139
140    let local_var_client = &local_var_configuration.client;
141
142    let local_var_uri_str = format!("{}/version", local_var_configuration.base_path);
143    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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    let mut local_var_form = reqwest::multipart::Form::new();
157    local_var_form = local_var_form.text("data", serde_json::to_string(&data)?);
158    local_var_req_builder = local_var_req_builder.multipart(local_var_form);
159
160    let local_var_req = local_var_req_builder.build()?;
161    let local_var_resp = local_var_client.execute(local_var_req).await?;
162
163    let local_var_status = local_var_resp.status();
164    let local_var_content = local_var_resp.text().await?;
165
166    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
167        serde_json::from_str(&local_var_content).map_err(Error::from)
168    } else {
169        let local_var_entity: Option<CreateVersionError> = serde_json::from_str(&local_var_content).ok();
170        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
171        Err(Error::ResponseError(local_var_error))
172    }
173}
174
175pub async fn delete_version(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteVersionError>> {
176    let local_var_configuration = configuration;
177
178    let local_var_client = &local_var_configuration.client;
179
180    let local_var_uri_str = format!("{}/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
181    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
182
183    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
184        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
185    }
186    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
187        let local_var_key = local_var_apikey.key.clone();
188        let local_var_value = match local_var_apikey.prefix {
189            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
190            None => local_var_key,
191        };
192        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
193    };
194
195    let local_var_req = local_var_req_builder.build()?;
196    let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198    let local_var_status = local_var_resp.status();
199    let local_var_content = local_var_resp.text().await?;
200
201    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202        Ok(())
203    } else {
204        let local_var_entity: Option<DeleteVersionError> = serde_json::from_str(&local_var_content).ok();
205        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206        Err(Error::ResponseError(local_var_error))
207    }
208}
209
210pub async fn get_project_versions(configuration: &configuration::Configuration, id_pipe_slug: &str, loaders: Option<&str>, game_versions: Option<&str>, featured: Option<bool>) -> Result<Vec<models::Version>, Error<GetProjectVersionsError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/project/{term_1}/version", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_str) = loaders {
219        local_var_req_builder = local_var_req_builder.query(&[("loaders", &local_var_str.to_string())]);
220    }
221    if let Some(ref local_var_str) = game_versions {
222        local_var_req_builder = local_var_req_builder.query(&[("game_versions", &local_var_str.to_string())]);
223    }
224    if let Some(ref local_var_str) = featured {
225        local_var_req_builder = local_var_req_builder.query(&[("featured", &local_var_str.to_string())]);
226    }
227    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
228        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
229    }
230
231    let local_var_req = local_var_req_builder.build()?;
232    let local_var_resp = local_var_client.execute(local_var_req).await?;
233
234    let local_var_status = local_var_resp.status();
235    let local_var_content = local_var_resp.text().await?;
236
237    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
238        serde_json::from_str(&local_var_content).map_err(Error::from)
239    } else {
240        let local_var_entity: Option<GetProjectVersionsError> = serde_json::from_str(&local_var_content).ok();
241        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
242        Err(Error::ResponseError(local_var_error))
243    }
244}
245
246pub async fn get_version(configuration: &configuration::Configuration, id: &str) -> Result<models::Version, Error<GetVersionError>> {
247    let local_var_configuration = configuration;
248
249    let local_var_client = &local_var_configuration.client;
250
251    let local_var_uri_str = format!("{}/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
252    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
253
254    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
255        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.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<GetVersionError> = serde_json::from_str(&local_var_content).ok();
268        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
269        Err(Error::ResponseError(local_var_error))
270    }
271}
272
273/// Please note that, if the version number provided matches multiple versions, only the **oldest matching version** will be returned.
274pub async fn get_version_from_id_or_number(configuration: &configuration::Configuration, id_pipe_slug: &str, id_pipe_number: &str) -> Result<models::Version, Error<GetVersionFromIdOrNumberError>> {
275    let local_var_configuration = configuration;
276
277    let local_var_client = &local_var_configuration.client;
278
279    let local_var_uri_str = format!("{}/project/{term_1}/version/{term_3}", local_var_configuration.base_path, term_1=crate::apis::urlencode(id_pipe_slug), term_3=crate::apis::urlencode(id_pipe_number));
280    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
281
282    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
283        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
284    }
285
286    let local_var_req = local_var_req_builder.build()?;
287    let local_var_resp = local_var_client.execute(local_var_req).await?;
288
289    let local_var_status = local_var_resp.status();
290    let local_var_content = local_var_resp.text().await?;
291
292    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
293        serde_json::from_str(&local_var_content).map_err(Error::from)
294    } else {
295        let local_var_entity: Option<GetVersionFromIdOrNumberError> = serde_json::from_str(&local_var_content).ok();
296        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
297        Err(Error::ResponseError(local_var_error))
298    }
299}
300
301pub async fn get_versions(configuration: &configuration::Configuration, ids: &str) -> Result<Vec<models::Version>, Error<GetVersionsError>> {
302    let local_var_configuration = configuration;
303
304    let local_var_client = &local_var_configuration.client;
305
306    let local_var_uri_str = format!("{}/versions", local_var_configuration.base_path);
307    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
308
309    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
310    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
311        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
312    }
313
314    let local_var_req = local_var_req_builder.build()?;
315    let local_var_resp = local_var_client.execute(local_var_req).await?;
316
317    let local_var_status = local_var_resp.status();
318    let local_var_content = local_var_resp.text().await?;
319
320    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
321        serde_json::from_str(&local_var_content).map_err(Error::from)
322    } else {
323        let local_var_entity: Option<GetVersionsError> = serde_json::from_str(&local_var_content).ok();
324        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
325        Err(Error::ResponseError(local_var_error))
326    }
327}
328
329pub async fn modify_version(configuration: &configuration::Configuration, id: &str, editable_version: Option<models::EditableVersion>) -> Result<(), Error<ModifyVersionError>> {
330    let local_var_configuration = configuration;
331
332    let local_var_client = &local_var_configuration.client;
333
334    let local_var_uri_str = format!("{}/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
335    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
336
337    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
338        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
339    }
340    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
341        let local_var_key = local_var_apikey.key.clone();
342        let local_var_value = match local_var_apikey.prefix {
343            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
344            None => local_var_key,
345        };
346        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
347    };
348    local_var_req_builder = local_var_req_builder.json(&editable_version);
349
350    let local_var_req = local_var_req_builder.build()?;
351    let local_var_resp = local_var_client.execute(local_var_req).await?;
352
353    let local_var_status = local_var_resp.status();
354    let local_var_content = local_var_resp.text().await?;
355
356    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
357        Ok(())
358    } else {
359        let local_var_entity: Option<ModifyVersionError> = serde_json::from_str(&local_var_content).ok();
360        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
361        Err(Error::ResponseError(local_var_error))
362    }
363}
364
365pub async fn schedule_version(configuration: &configuration::Configuration, id: &str, schedule: Option<models::Schedule>) -> Result<(), Error<ScheduleVersionError>> {
366    let local_var_configuration = configuration;
367
368    let local_var_client = &local_var_configuration.client;
369
370    let local_var_uri_str = format!("{}/version/{id}/schedule", local_var_configuration.base_path, id=crate::apis::urlencode(id));
371    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
374        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375    }
376    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
377        let local_var_key = local_var_apikey.key.clone();
378        let local_var_value = match local_var_apikey.prefix {
379            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
380            None => local_var_key,
381        };
382        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
383    };
384    local_var_req_builder = local_var_req_builder.json(&schedule);
385
386    let local_var_req = local_var_req_builder.build()?;
387    let local_var_resp = local_var_client.execute(local_var_req).await?;
388
389    let local_var_status = local_var_resp.status();
390    let local_var_content = local_var_resp.text().await?;
391
392    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
393        Ok(())
394    } else {
395        let local_var_entity: Option<ScheduleVersionError> = serde_json::from_str(&local_var_content).ok();
396        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
397        Err(Error::ResponseError(local_var_error))
398    }
399}
400