1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ChannelScanError {
22 Status409(crate::models::Error),
23 DefaultResponse(crate::models::Error),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetChannelsConfigError {
31 DefaultResponse(crate::models::Error),
32 UnknownValue(serde_json::Value),
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum GetServerConfigError {
39 DefaultResponse(crate::models::Error),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum GetTunersConfigError {
47 DefaultResponse(crate::models::Error),
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum UpdateChannelsConfigError {
55 DefaultResponse(crate::models::Error),
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum UpdateServerConfigError {
63 DefaultResponse(crate::models::Error),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum UpdateTunersConfigError {
71 DefaultResponse(crate::models::Error),
72 UnknownValue(serde_json::Value),
73}
74
75
76pub fn channel_scan(configuration: &configuration::Configuration, dry_run: Option<bool>, _type: Option<&str>, min_ch: Option<i32>, max_ch: Option<i32>, min_sub_ch: Option<i32>, max_sub_ch: Option<i32>, use_sub_ch: Option<bool>, scan_mode: Option<&str>, set_disabled_on_add: Option<bool>, refresh: Option<bool>) -> Result<(), Error<ChannelScanError>> {
78 let local_var_configuration = configuration;
79
80 let local_var_client = &local_var_configuration.client;
81
82 let local_var_uri_str = format!("{}/config/channels/scan", local_var_configuration.base_path);
83 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
84
85 if let Some(ref local_var_str) = dry_run {
86 local_var_req_builder = local_var_req_builder.query(&[("dryRun", &local_var_str.to_string())]);
87 }
88 if let Some(ref local_var_str) = _type {
89 local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
90 }
91 if let Some(ref local_var_str) = min_ch {
92 local_var_req_builder = local_var_req_builder.query(&[("minCh", &local_var_str.to_string())]);
93 }
94 if let Some(ref local_var_str) = max_ch {
95 local_var_req_builder = local_var_req_builder.query(&[("maxCh", &local_var_str.to_string())]);
96 }
97 if let Some(ref local_var_str) = min_sub_ch {
98 local_var_req_builder = local_var_req_builder.query(&[("minSubCh", &local_var_str.to_string())]);
99 }
100 if let Some(ref local_var_str) = max_sub_ch {
101 local_var_req_builder = local_var_req_builder.query(&[("maxSubCh", &local_var_str.to_string())]);
102 }
103 if let Some(ref local_var_str) = use_sub_ch {
104 local_var_req_builder = local_var_req_builder.query(&[("useSubCh", &local_var_str.to_string())]);
105 }
106 if let Some(ref local_var_str) = scan_mode {
107 local_var_req_builder = local_var_req_builder.query(&[("scanMode", &local_var_str.to_string())]);
108 }
109 if let Some(ref local_var_str) = set_disabled_on_add {
110 local_var_req_builder = local_var_req_builder.query(&[("setDisabledOnAdd", &local_var_str.to_string())]);
111 }
112 if let Some(ref local_var_str) = refresh {
113 local_var_req_builder = local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
114 }
115 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
116 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
117 }
118
119 let local_var_req = local_var_req_builder.build()?;
120 let mut local_var_resp = local_var_client.execute(local_var_req)?;
121
122 let local_var_status = local_var_resp.status();
123 let local_var_content = local_var_resp.text()?;
124
125 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
126 Ok(())
127 } else {
128 let local_var_entity: Option<ChannelScanError> = serde_json::from_str(&local_var_content).ok();
129 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
130 Err(Error::ResponseError(local_var_error))
131 }
132}
133
134pub fn get_channels_config(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::ConfigChannelsItem>, Error<GetChannelsConfigError>> {
135 let local_var_configuration = configuration;
136
137 let local_var_client = &local_var_configuration.client;
138
139 let local_var_uri_str = format!("{}/config/channels", local_var_configuration.base_path);
140 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
141
142 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
143 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
144 }
145
146 let local_var_req = local_var_req_builder.build()?;
147 let mut local_var_resp = local_var_client.execute(local_var_req)?;
148
149 let local_var_status = local_var_resp.status();
150 let local_var_content = local_var_resp.text()?;
151
152 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
153 serde_json::from_str(&local_var_content).map_err(Error::from)
154 } else {
155 let local_var_entity: Option<GetChannelsConfigError> = serde_json::from_str(&local_var_content).ok();
156 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
157 Err(Error::ResponseError(local_var_error))
158 }
159}
160
161pub fn get_server_config(configuration: &configuration::Configuration, ) -> Result<crate::models::ConfigServer, Error<GetServerConfigError>> {
162 let local_var_configuration = configuration;
163
164 let local_var_client = &local_var_configuration.client;
165
166 let local_var_uri_str = format!("{}/config/server", local_var_configuration.base_path);
167 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
168
169 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
170 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
171 }
172
173 let local_var_req = local_var_req_builder.build()?;
174 let mut local_var_resp = local_var_client.execute(local_var_req)?;
175
176 let local_var_status = local_var_resp.status();
177 let local_var_content = local_var_resp.text()?;
178
179 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180 serde_json::from_str(&local_var_content).map_err(Error::from)
181 } else {
182 let local_var_entity: Option<GetServerConfigError> = serde_json::from_str(&local_var_content).ok();
183 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184 Err(Error::ResponseError(local_var_error))
185 }
186}
187
188pub fn get_tuners_config(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::ConfigTunersItem>, Error<GetTunersConfigError>> {
189 let local_var_configuration = configuration;
190
191 let local_var_client = &local_var_configuration.client;
192
193 let local_var_uri_str = format!("{}/config/tuners", local_var_configuration.base_path);
194 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
195
196 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
198 }
199
200 let local_var_req = local_var_req_builder.build()?;
201 let mut local_var_resp = local_var_client.execute(local_var_req)?;
202
203 let local_var_status = local_var_resp.status();
204 let local_var_content = local_var_resp.text()?;
205
206 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
207 serde_json::from_str(&local_var_content).map_err(Error::from)
208 } else {
209 let local_var_entity: Option<GetTunersConfigError> = serde_json::from_str(&local_var_content).ok();
210 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
211 Err(Error::ResponseError(local_var_error))
212 }
213}
214
215pub fn update_channels_config(configuration: &configuration::Configuration, body: Option<Vec<crate::models::ConfigChannelsItem>>) -> Result<Vec<crate::models::ConfigChannelsItem>, Error<UpdateChannelsConfigError>> {
216 let local_var_configuration = configuration;
217
218 let local_var_client = &local_var_configuration.client;
219
220 let local_var_uri_str = format!("{}/config/channels", local_var_configuration.base_path);
221 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
222
223 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
224 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
225 }
226 local_var_req_builder = local_var_req_builder.json(&body);
227
228 let local_var_req = local_var_req_builder.build()?;
229 let mut local_var_resp = local_var_client.execute(local_var_req)?;
230
231 let local_var_status = local_var_resp.status();
232 let local_var_content = local_var_resp.text()?;
233
234 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235 serde_json::from_str(&local_var_content).map_err(Error::from)
236 } else {
237 let local_var_entity: Option<UpdateChannelsConfigError> = serde_json::from_str(&local_var_content).ok();
238 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239 Err(Error::ResponseError(local_var_error))
240 }
241}
242
243pub fn update_server_config(configuration: &configuration::Configuration, body: Option<crate::models::ConfigServer>) -> Result<crate::models::ConfigServer, Error<UpdateServerConfigError>> {
244 let local_var_configuration = configuration;
245
246 let local_var_client = &local_var_configuration.client;
247
248 let local_var_uri_str = format!("{}/config/server", local_var_configuration.base_path);
249 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
250
251 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
252 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
253 }
254 local_var_req_builder = local_var_req_builder.json(&body);
255
256 let local_var_req = local_var_req_builder.build()?;
257 let mut local_var_resp = local_var_client.execute(local_var_req)?;
258
259 let local_var_status = local_var_resp.status();
260 let local_var_content = local_var_resp.text()?;
261
262 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
263 serde_json::from_str(&local_var_content).map_err(Error::from)
264 } else {
265 let local_var_entity: Option<UpdateServerConfigError> = serde_json::from_str(&local_var_content).ok();
266 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
267 Err(Error::ResponseError(local_var_error))
268 }
269}
270
271pub fn update_tuners_config(configuration: &configuration::Configuration, body: Option<Vec<crate::models::ConfigTunersItem>>) -> Result<Vec<crate::models::ConfigTunersItem>, Error<UpdateTunersConfigError>> {
272 let local_var_configuration = configuration;
273
274 let local_var_client = &local_var_configuration.client;
275
276 let local_var_uri_str = format!("{}/config/tuners", local_var_configuration.base_path);
277 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
278
279 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
280 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
281 }
282 local_var_req_builder = local_var_req_builder.json(&body);
283
284 let local_var_req = local_var_req_builder.build()?;
285 let mut local_var_resp = local_var_client.execute(local_var_req)?;
286
287 let local_var_status = local_var_resp.status();
288 let local_var_content = local_var_resp.text()?;
289
290 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
291 serde_json::from_str(&local_var_content).map_err(Error::from)
292 } else {
293 let local_var_entity: Option<UpdateTunersConfigError> = serde_json::from_str(&local_var_content).ok();
294 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
295 Err(Error::ResponseError(local_var_error))
296 }
297}
298