1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConfigMediaPoolCreateMediaPoolError {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConfigMediaPoolDeleteMediaPoolError {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ConfigMediaPoolGetConfigMediaPoolByNameError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ConfigMediaPoolGetMediaPoolError {
64 Status400(models::PbsError),
65 Status401(models::PbsError),
66 Status403(models::PbsError),
67 Status404(models::PbsError),
68 Status500(models::PbsError),
69 Status501(models::PbsError),
70 Status503(models::PbsError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConfigMediaPoolUpdateMediaPoolError {
78 Status400(models::PbsError),
79 Status401(models::PbsError),
80 Status403(models::PbsError),
81 Status404(models::PbsError),
82 Status500(models::PbsError),
83 Status501(models::PbsError),
84 Status503(models::PbsError),
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn config_media_pool_create_media_pool(configuration: &configuration::Configuration, config_media_pool_create_media_pool_request: models::ConfigMediaPoolCreateMediaPoolRequest) -> Result<models::ConfigMediaPoolCreateMediaPoolResponse, Error<ConfigMediaPoolCreateMediaPoolError>> {
91 let p_body_config_media_pool_create_media_pool_request = config_media_pool_create_media_pool_request;
93
94 let uri_str = format!("{}/config/media-pool", configuration.base_path);
95 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
96
97 if let Some(ref user_agent) = configuration.user_agent {
98 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99 }
100 if let Some(ref apikey) = configuration.api_key {
101 let key = apikey.key.clone();
102 let value = match apikey.prefix {
103 Some(ref prefix) => format!("{} {}", prefix, key),
104 None => key,
105 };
106 req_builder = req_builder.header("Authorization", value);
107 };
108 if let Some(ref apikey) = configuration.api_key {
109 let key = apikey.key.clone();
110 let value = match apikey.prefix {
111 Some(ref prefix) => format!("{} {}", prefix, key),
112 None => key,
113 };
114 req_builder = req_builder.header("CSRFPreventionToken", value);
115 };
116 req_builder = req_builder.json(&p_body_config_media_pool_create_media_pool_request);
117
118 let req = req_builder.build()?;
119 let resp = configuration.client.execute(req).await?;
120
121 let status = resp.status();
122 let content_type = resp
123 .headers()
124 .get("content-type")
125 .and_then(|v| v.to_str().ok())
126 .unwrap_or("application/octet-stream");
127 let content_type = super::ContentType::from(content_type);
128
129 if !status.is_client_error() && !status.is_server_error() {
130 let content = resp.text().await?;
131 match content_type {
132 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
133 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMediaPoolCreateMediaPoolResponse`"))),
134 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigMediaPoolCreateMediaPoolResponse`")))),
135 }
136 } else {
137 let content = resp.text().await?;
138 let entity: Option<ConfigMediaPoolCreateMediaPoolError> = serde_json::from_str(&content).ok();
139 Err(Error::ResponseError(ResponseContent { status, content, entity }))
140 }
141}
142
143pub async fn config_media_pool_delete_media_pool(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigMediaPoolDeleteMediaPoolResponse, Error<ConfigMediaPoolDeleteMediaPoolError>> {
145 let p_path_name = name;
147
148 let uri_str = format!("{}/config/media-pool/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
149 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
150
151 if let Some(ref user_agent) = configuration.user_agent {
152 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
153 }
154 if let Some(ref apikey) = configuration.api_key {
155 let key = apikey.key.clone();
156 let value = match apikey.prefix {
157 Some(ref prefix) => format!("{} {}", prefix, key),
158 None => key,
159 };
160 req_builder = req_builder.header("Authorization", value);
161 };
162 if let Some(ref apikey) = configuration.api_key {
163 let key = apikey.key.clone();
164 let value = match apikey.prefix {
165 Some(ref prefix) => format!("{} {}", prefix, key),
166 None => key,
167 };
168 req_builder = req_builder.header("CSRFPreventionToken", value);
169 };
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMediaPoolDeleteMediaPoolResponse`"))),
187 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigMediaPoolDeleteMediaPoolResponse`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<ConfigMediaPoolDeleteMediaPoolError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent { status, content, entity }))
193 }
194}
195
196pub async fn config_media_pool_get_config_media_pool_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigMediaPoolGetConfigMediaPoolByNameResponse, Error<ConfigMediaPoolGetConfigMediaPoolByNameError>> {
198 let p_path_name = name;
200
201 let uri_str = format!("{}/config/media-pool/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
202 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
203
204 if let Some(ref user_agent) = configuration.user_agent {
205 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
206 }
207 if let Some(ref apikey) = configuration.api_key {
208 let key = apikey.key.clone();
209 let value = match apikey.prefix {
210 Some(ref prefix) => format!("{} {}", prefix, key),
211 None => key,
212 };
213 req_builder = req_builder.header("Authorization", value);
214 };
215 if let Some(ref apikey) = configuration.api_key {
216 let key = apikey.key.clone();
217 let value = match apikey.prefix {
218 Some(ref prefix) => format!("{} {}", prefix, key),
219 None => key,
220 };
221 req_builder = req_builder.header("CSRFPreventionToken", value);
222 };
223
224 let req = req_builder.build()?;
225 let resp = configuration.client.execute(req).await?;
226
227 let status = resp.status();
228 let content_type = resp
229 .headers()
230 .get("content-type")
231 .and_then(|v| v.to_str().ok())
232 .unwrap_or("application/octet-stream");
233 let content_type = super::ContentType::from(content_type);
234
235 if !status.is_client_error() && !status.is_server_error() {
236 let content = resp.text().await?;
237 match content_type {
238 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
239 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMediaPoolGetConfigMediaPoolByNameResponse`"))),
240 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigMediaPoolGetConfigMediaPoolByNameResponse`")))),
241 }
242 } else {
243 let content = resp.text().await?;
244 let entity: Option<ConfigMediaPoolGetConfigMediaPoolByNameError> = serde_json::from_str(&content).ok();
245 Err(Error::ResponseError(ResponseContent { status, content, entity }))
246 }
247}
248
249pub async fn config_media_pool_get_media_pool(configuration: &configuration::Configuration, ) -> Result<models::ConfigMediaPoolGetMediaPoolResponse, Error<ConfigMediaPoolGetMediaPoolError>> {
251
252 let uri_str = format!("{}/config/media-pool", configuration.base_path);
253 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
254
255 if let Some(ref user_agent) = configuration.user_agent {
256 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
257 }
258 if let Some(ref apikey) = configuration.api_key {
259 let key = apikey.key.clone();
260 let value = match apikey.prefix {
261 Some(ref prefix) => format!("{} {}", prefix, key),
262 None => key,
263 };
264 req_builder = req_builder.header("Authorization", value);
265 };
266 if let Some(ref apikey) = configuration.api_key {
267 let key = apikey.key.clone();
268 let value = match apikey.prefix {
269 Some(ref prefix) => format!("{} {}", prefix, key),
270 None => key,
271 };
272 req_builder = req_builder.header("CSRFPreventionToken", value);
273 };
274
275 let req = req_builder.build()?;
276 let resp = configuration.client.execute(req).await?;
277
278 let status = resp.status();
279 let content_type = resp
280 .headers()
281 .get("content-type")
282 .and_then(|v| v.to_str().ok())
283 .unwrap_or("application/octet-stream");
284 let content_type = super::ContentType::from(content_type);
285
286 if !status.is_client_error() && !status.is_server_error() {
287 let content = resp.text().await?;
288 match content_type {
289 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
290 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMediaPoolGetMediaPoolResponse`"))),
291 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigMediaPoolGetMediaPoolResponse`")))),
292 }
293 } else {
294 let content = resp.text().await?;
295 let entity: Option<ConfigMediaPoolGetMediaPoolError> = serde_json::from_str(&content).ok();
296 Err(Error::ResponseError(ResponseContent { status, content, entity }))
297 }
298}
299
300pub async fn config_media_pool_update_media_pool(configuration: &configuration::Configuration, name: &str, config_media_pool_update_media_pool_request: Option<models::ConfigMediaPoolUpdateMediaPoolRequest>) -> Result<models::ConfigMediaPoolUpdateMediaPoolResponse, Error<ConfigMediaPoolUpdateMediaPoolError>> {
302 let p_path_name = name;
304 let p_body_config_media_pool_update_media_pool_request = config_media_pool_update_media_pool_request;
305
306 let uri_str = format!("{}/config/media-pool/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
307 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
308
309 if let Some(ref user_agent) = configuration.user_agent {
310 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
311 }
312 if let Some(ref apikey) = configuration.api_key {
313 let key = apikey.key.clone();
314 let value = match apikey.prefix {
315 Some(ref prefix) => format!("{} {}", prefix, key),
316 None => key,
317 };
318 req_builder = req_builder.header("Authorization", value);
319 };
320 if let Some(ref apikey) = configuration.api_key {
321 let key = apikey.key.clone();
322 let value = match apikey.prefix {
323 Some(ref prefix) => format!("{} {}", prefix, key),
324 None => key,
325 };
326 req_builder = req_builder.header("CSRFPreventionToken", value);
327 };
328 req_builder = req_builder.json(&p_body_config_media_pool_update_media_pool_request);
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334 let content_type = resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let content_type = super::ContentType::from(content_type);
340
341 if !status.is_client_error() && !status.is_server_error() {
342 let content = resp.text().await?;
343 match content_type {
344 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMediaPoolUpdateMediaPoolResponse`"))),
346 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ConfigMediaPoolUpdateMediaPoolResponse`")))),
347 }
348 } else {
349 let content = resp.text().await?;
350 let entity: Option<ConfigMediaPoolUpdateMediaPoolError> = serde_json::from_str(&content).ok();
351 Err(Error::ResponseError(ResponseContent { status, content, entity }))
352 }
353}
354