radarr_api_rs/apis/
queue_details_api.rs

1/*
2 * Radarr
3 *
4 * Radarr API docs
5 *
6 * The version of the OpenAPI document: 3.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`api_v3_queue_details_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3QueueDetailsGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_queue_details_id_get`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3QueueDetailsIdGetError {
29    UnknownValue(serde_json::Value),
30}
31
32
33pub async fn api_v3_queue_details_get(configuration: &configuration::Configuration, movie_id: Option<i32>, include_movie: Option<bool>) -> Result<Vec<crate::models::QueueResource>, Error<ApiV3QueueDetailsGetError>> {
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/queue/details", 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) = movie_id {
42        local_var_req_builder = local_var_req_builder.query(&[("movieId", &local_var_str.to_string())]);
43    }
44    if let Some(ref local_var_str) = include_movie {
45        local_var_req_builder = local_var_req_builder.query(&[("includeMovie", &local_var_str.to_string())]);
46    }
47    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
48        let local_var_key = local_var_apikey.key.clone();
49        let local_var_value = match local_var_apikey.prefix {
50            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
51            None => local_var_key,
52        };
53        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
54    }
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
59        let local_var_key = local_var_apikey.key.clone();
60        let local_var_value = match local_var_apikey.prefix {
61            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
62            None => local_var_key,
63        };
64        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
65    };
66
67    let local_var_req = local_var_req_builder.build()?;
68    let local_var_resp = local_var_client.execute(local_var_req).await?;
69
70    let local_var_status = local_var_resp.status();
71    let local_var_content = local_var_resp.text().await?;
72
73    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
74        serde_json::from_str(&local_var_content).map_err(Error::from)
75    } else {
76        let local_var_entity: Option<ApiV3QueueDetailsGetError> = serde_json::from_str(&local_var_content).ok();
77        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
78        Err(Error::ResponseError(local_var_error))
79    }
80}
81
82pub async fn api_v3_queue_details_id_get(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::QueueResource, Error<ApiV3QueueDetailsIdGetError>> {
83    let local_var_configuration = configuration;
84
85    let local_var_client = &local_var_configuration.client;
86
87    let local_var_uri_str = format!("{}/api/v3/queue/details/{id}", local_var_configuration.base_path, id=id);
88    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
89
90    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
91        let local_var_key = local_var_apikey.key.clone();
92        let local_var_value = match local_var_apikey.prefix {
93            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
94            None => local_var_key,
95        };
96        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
97    }
98    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
99        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
102        let local_var_key = local_var_apikey.key.clone();
103        let local_var_value = match local_var_apikey.prefix {
104            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
105            None => local_var_key,
106        };
107        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
108    };
109
110    let local_var_req = local_var_req_builder.build()?;
111    let local_var_resp = local_var_client.execute(local_var_req).await?;
112
113    let local_var_status = local_var_resp.status();
114    let local_var_content = local_var_resp.text().await?;
115
116    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
117        serde_json::from_str(&local_var_content).map_err(Error::from)
118    } else {
119        let local_var_entity: Option<ApiV3QueueDetailsIdGetError> = serde_json::from_str(&local_var_content).ok();
120        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
121        Err(Error::ResponseError(local_var_error))
122    }
123}
124