radarr_api_rs/apis/
import_list_movies_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3ImportlistMovieGetError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3ImportlistMoviePostError {
29 UnknownValue(serde_json::Value),
30}
31
32
33pub async fn api_v3_importlist_movie_get(configuration: &configuration::Configuration, include_recommendations: Option<bool>) -> Result<(), Error<ApiV3ImportlistMovieGetError>> {
34 let local_var_configuration = configuration;
35
36 let local_var_client = &local_var_configuration.client;
37
38 let local_var_uri_str = format!("{}/api/v3/importlist/movie", local_var_configuration.base_path);
39 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
40
41 if let Some(ref local_var_str) = include_recommendations {
42 local_var_req_builder = local_var_req_builder.query(&[("includeRecommendations", &local_var_str.to_string())]);
43 }
44 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
45 let local_var_key = local_var_apikey.key.clone();
46 let local_var_value = match local_var_apikey.prefix {
47 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
48 None => local_var_key,
49 };
50 local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
51 }
52 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
53 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
54 }
55 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
56 let local_var_key = local_var_apikey.key.clone();
57 let local_var_value = match local_var_apikey.prefix {
58 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
59 None => local_var_key,
60 };
61 local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
62 };
63
64 let local_var_req = local_var_req_builder.build()?;
65 let local_var_resp = local_var_client.execute(local_var_req).await?;
66
67 let local_var_status = local_var_resp.status();
68 let local_var_content = local_var_resp.text().await?;
69
70 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
71 Ok(())
72 } else {
73 let local_var_entity: Option<ApiV3ImportlistMovieGetError> = serde_json::from_str(&local_var_content).ok();
74 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
75 Err(Error::ResponseError(local_var_error))
76 }
77}
78
79pub async fn api_v3_importlist_movie_post(configuration: &configuration::Configuration, movie_resource: Option<Vec<crate::models::MovieResource>>) -> Result<(), Error<ApiV3ImportlistMoviePostError>> {
80 let local_var_configuration = configuration;
81
82 let local_var_client = &local_var_configuration.client;
83
84 let local_var_uri_str = format!("{}/api/v3/importlist/movie", local_var_configuration.base_path);
85 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
86
87 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
88 let local_var_key = local_var_apikey.key.clone();
89 let local_var_value = match local_var_apikey.prefix {
90 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
91 None => local_var_key,
92 };
93 local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
94 }
95 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
96 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
97 }
98 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
99 let local_var_key = local_var_apikey.key.clone();
100 let local_var_value = match local_var_apikey.prefix {
101 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
102 None => local_var_key,
103 };
104 local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
105 };
106 local_var_req_builder = local_var_req_builder.json(&movie_resource);
107
108 let local_var_req = local_var_req_builder.build()?;
109 let local_var_resp = local_var_client.execute(local_var_req).await?;
110
111 let local_var_status = local_var_resp.status();
112 let local_var_content = local_var_resp.text().await?;
113
114 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
115 Ok(())
116 } else {
117 let local_var_entity: Option<ApiV3ImportlistMoviePostError> = serde_json::from_str(&local_var_content).ok();
118 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
119 Err(Error::ResponseError(local_var_error))
120 }
121}
122