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 AttachGalaxyClusterError {
22 Status403(models::UnauthorizedApiError),
23 Status404(models::NotFoundApiError),
24 DefaultResponse(models::ApiError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DeleteGalaxyError {
32 Status403(models::UnauthorizedApiError),
33 Status404(models::NotFoundApiError),
34 DefaultResponse(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum ExportGalaxyClustersError {
42 Status403(models::UnauthorizedApiError),
43 Status404(models::NotFoundApiError),
44 DefaultResponse(models::ApiError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetGalaxiesError {
52 Status403(models::UnauthorizedApiError),
53 DefaultResponse(models::ApiError),
54 UnknownValue(serde_json::Value),
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetGalaxyByIdError {
61 Status403(models::UnauthorizedApiError),
62 DefaultResponse(models::ApiError),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ImportGalaxyClusterError {
70 Status403(models::UnauthorizedApiError),
71 Status404(models::NotFoundApiError),
72 DefaultResponse(models::ApiError),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum SearchGalaxiesError {
80 Status403(models::UnauthorizedApiError),
81 DefaultResponse(models::ApiError),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum UpdateGalaxiesError {
89 Status403(models::UnauthorizedApiError),
90 Status404(models::NotFoundApiError),
91 DefaultResponse(models::ApiError),
92 UnknownValue(serde_json::Value),
93}
94
95
96pub async fn attach_galaxy_cluster(configuration: &configuration::Configuration, attach_target_id: &str, attach_target_type: &str, local: bool, attach_galaxy_cluster_request: Option<models::AttachGalaxyClusterRequest>) -> Result<models::AttachGalaxyCluster200Response, Error<AttachGalaxyClusterError>> {
97 let p_attach_target_id = attach_target_id;
99 let p_attach_target_type = attach_target_type;
100 let p_local = local;
101 let p_attach_galaxy_cluster_request = attach_galaxy_cluster_request;
102
103 let uri_str = format!("{}/galaxies/attachCluster/{attachTargetId}/{attachTargetType}/local:{local}", configuration.base_path, attachTargetId=p_attach_target_id.to_string(), attachTargetType=crate::apis::urlencode(p_attach_target_type), local=p_local);
104 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
105
106 if let Some(ref user_agent) = configuration.user_agent {
107 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
108 }
109 if let Some(ref apikey) = configuration.api_key {
110 let key = apikey.key.clone();
111 let value = match apikey.prefix {
112 Some(ref prefix) => format!("{} {}", prefix, key),
113 None => key,
114 };
115 req_builder = req_builder.header("Authorization", value);
116 };
117 req_builder = req_builder.json(&p_attach_galaxy_cluster_request);
118
119 let req = req_builder.build()?;
120 let resp = configuration.client.execute(req).await?;
121
122 let status = resp.status();
123 let content_type = resp
124 .headers()
125 .get("content-type")
126 .and_then(|v| v.to_str().ok())
127 .unwrap_or("application/octet-stream");
128 let content_type = super::ContentType::from(content_type);
129
130 if !status.is_client_error() && !status.is_server_error() {
131 let content = resp.text().await?;
132 match content_type {
133 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
134 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachGalaxyCluster200Response`"))),
135 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::AttachGalaxyCluster200Response`")))),
136 }
137 } else {
138 let content = resp.text().await?;
139 let entity: Option<AttachGalaxyClusterError> = serde_json::from_str(&content).ok();
140 Err(Error::ResponseError(ResponseContent { status, content, entity }))
141 }
142}
143
144pub async fn delete_galaxy(configuration: &configuration::Configuration, galaxy_id: &str) -> Result<models::DeleteGalaxy200Response, Error<DeleteGalaxyError>> {
145 let p_galaxy_id = galaxy_id;
147
148 let uri_str = format!("{}/galaxies/delete/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
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
163 let req = req_builder.build()?;
164 let resp = configuration.client.execute(req).await?;
165
166 let status = resp.status();
167 let content_type = resp
168 .headers()
169 .get("content-type")
170 .and_then(|v| v.to_str().ok())
171 .unwrap_or("application/octet-stream");
172 let content_type = super::ContentType::from(content_type);
173
174 if !status.is_client_error() && !status.is_server_error() {
175 let content = resp.text().await?;
176 match content_type {
177 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
178 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteGalaxy200Response`"))),
179 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::DeleteGalaxy200Response`")))),
180 }
181 } else {
182 let content = resp.text().await?;
183 let entity: Option<DeleteGalaxyError> = serde_json::from_str(&content).ok();
184 Err(Error::ResponseError(ResponseContent { status, content, entity }))
185 }
186}
187
188pub async fn export_galaxy_clusters(configuration: &configuration::Configuration, galaxy_id: &str, export_galaxy_clusters_request: Option<models::ExportGalaxyClustersRequest>) -> Result<models::ExportGalaxyClusters200Response, Error<ExportGalaxyClustersError>> {
189 let p_galaxy_id = galaxy_id;
191 let p_export_galaxy_clusters_request = export_galaxy_clusters_request;
192
193 let uri_str = format!("{}/galaxies/export/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
194 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
195
196 if let Some(ref user_agent) = configuration.user_agent {
197 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
198 }
199 if let Some(ref apikey) = configuration.api_key {
200 let key = apikey.key.clone();
201 let value = match apikey.prefix {
202 Some(ref prefix) => format!("{} {}", prefix, key),
203 None => key,
204 };
205 req_builder = req_builder.header("Authorization", value);
206 };
207 req_builder = req_builder.json(&p_export_galaxy_clusters_request);
208
209 let req = req_builder.build()?;
210 let resp = configuration.client.execute(req).await?;
211
212 let status = resp.status();
213 let content_type = resp
214 .headers()
215 .get("content-type")
216 .and_then(|v| v.to_str().ok())
217 .unwrap_or("application/octet-stream");
218 let content_type = super::ContentType::from(content_type);
219
220 if !status.is_client_error() && !status.is_server_error() {
221 let content = resp.text().await?;
222 match content_type {
223 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExportGalaxyClusters200Response`"))),
225 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::ExportGalaxyClusters200Response`")))),
226 }
227 } else {
228 let content = resp.text().await?;
229 let entity: Option<ExportGalaxyClustersError> = serde_json::from_str(&content).ok();
230 Err(Error::ResponseError(ResponseContent { status, content, entity }))
231 }
232}
233
234pub async fn get_galaxies(configuration: &configuration::Configuration, ) -> Result<Vec<models::GetGalaxies200ResponseInner>, Error<GetGalaxiesError>> {
235
236 let uri_str = format!("{}/galaxies", configuration.base_path);
237 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
238
239 if let Some(ref user_agent) = configuration.user_agent {
240 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
241 }
242 if let Some(ref apikey) = configuration.api_key {
243 let key = apikey.key.clone();
244 let value = match apikey.prefix {
245 Some(ref prefix) => format!("{} {}", prefix, key),
246 None => key,
247 };
248 req_builder = req_builder.header("Authorization", value);
249 };
250
251 let req = req_builder.build()?;
252 let resp = configuration.client.execute(req).await?;
253
254 let status = resp.status();
255 let content_type = resp
256 .headers()
257 .get("content-type")
258 .and_then(|v| v.to_str().ok())
259 .unwrap_or("application/octet-stream");
260 let content_type = super::ContentType::from(content_type);
261
262 if !status.is_client_error() && !status.is_server_error() {
263 let content = resp.text().await?;
264 match content_type {
265 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
266 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetGalaxies200ResponseInner>`"))),
267 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetGalaxies200ResponseInner>`")))),
268 }
269 } else {
270 let content = resp.text().await?;
271 let entity: Option<GetGalaxiesError> = serde_json::from_str(&content).ok();
272 Err(Error::ResponseError(ResponseContent { status, content, entity }))
273 }
274}
275
276pub async fn get_galaxy_by_id(configuration: &configuration::Configuration, galaxy_id: &str) -> Result<models::ExtendedGalaxy, Error<GetGalaxyByIdError>> {
277 let p_galaxy_id = galaxy_id;
279
280 let uri_str = format!("{}/galaxies/view/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
281 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
282
283 if let Some(ref user_agent) = configuration.user_agent {
284 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
285 }
286 if let Some(ref apikey) = configuration.api_key {
287 let key = apikey.key.clone();
288 let value = match apikey.prefix {
289 Some(ref prefix) => format!("{} {}", prefix, key),
290 None => key,
291 };
292 req_builder = req_builder.header("Authorization", value);
293 };
294
295 let req = req_builder.build()?;
296 let resp = configuration.client.execute(req).await?;
297
298 let status = resp.status();
299 let content_type = resp
300 .headers()
301 .get("content-type")
302 .and_then(|v| v.to_str().ok())
303 .unwrap_or("application/octet-stream");
304 let content_type = super::ContentType::from(content_type);
305
306 if !status.is_client_error() && !status.is_server_error() {
307 let content = resp.text().await?;
308 match content_type {
309 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
310 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtendedGalaxy`"))),
311 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::ExtendedGalaxy`")))),
312 }
313 } else {
314 let content = resp.text().await?;
315 let entity: Option<GetGalaxyByIdError> = serde_json::from_str(&content).ok();
316 Err(Error::ResponseError(ResponseContent { status, content, entity }))
317 }
318}
319
320pub async fn import_galaxy_cluster(configuration: &configuration::Configuration, import_galaxy_cluster_item: Vec<models::ImportGalaxyClusterItem>) -> Result<models::ImportGalaxyCluster200Response, Error<ImportGalaxyClusterError>> {
321 let p_import_galaxy_cluster_item = import_galaxy_cluster_item;
323
324 let uri_str = format!("{}/galaxies/import", configuration.base_path);
325 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
326
327 if let Some(ref user_agent) = configuration.user_agent {
328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329 }
330 if let Some(ref apikey) = configuration.api_key {
331 let key = apikey.key.clone();
332 let value = match apikey.prefix {
333 Some(ref prefix) => format!("{} {}", prefix, key),
334 None => key,
335 };
336 req_builder = req_builder.header("Authorization", value);
337 };
338 req_builder = req_builder.json(&p_import_galaxy_cluster_item);
339
340 let req = req_builder.build()?;
341 let resp = configuration.client.execute(req).await?;
342
343 let status = resp.status();
344 let content_type = resp
345 .headers()
346 .get("content-type")
347 .and_then(|v| v.to_str().ok())
348 .unwrap_or("application/octet-stream");
349 let content_type = super::ContentType::from(content_type);
350
351 if !status.is_client_error() && !status.is_server_error() {
352 let content = resp.text().await?;
353 match content_type {
354 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
355 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportGalaxyCluster200Response`"))),
356 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::ImportGalaxyCluster200Response`")))),
357 }
358 } else {
359 let content = resp.text().await?;
360 let entity: Option<ImportGalaxyClusterError> = serde_json::from_str(&content).ok();
361 Err(Error::ResponseError(ResponseContent { status, content, entity }))
362 }
363}
364
365pub async fn search_galaxies(configuration: &configuration::Configuration, search_galaxies_request: models::SearchGalaxiesRequest) -> Result<Vec<models::GetGalaxies200ResponseInner>, Error<SearchGalaxiesError>> {
366 let p_search_galaxies_request = search_galaxies_request;
368
369 let uri_str = format!("{}/galaxies", configuration.base_path);
370 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
371
372 if let Some(ref user_agent) = configuration.user_agent {
373 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374 }
375 if let Some(ref apikey) = configuration.api_key {
376 let key = apikey.key.clone();
377 let value = match apikey.prefix {
378 Some(ref prefix) => format!("{} {}", prefix, key),
379 None => key,
380 };
381 req_builder = req_builder.header("Authorization", value);
382 };
383 req_builder = req_builder.json(&p_search_galaxies_request);
384
385 let req = req_builder.build()?;
386 let resp = configuration.client.execute(req).await?;
387
388 let status = resp.status();
389 let content_type = resp
390 .headers()
391 .get("content-type")
392 .and_then(|v| v.to_str().ok())
393 .unwrap_or("application/octet-stream");
394 let content_type = super::ContentType::from(content_type);
395
396 if !status.is_client_error() && !status.is_server_error() {
397 let content = resp.text().await?;
398 match content_type {
399 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
400 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetGalaxies200ResponseInner>`"))),
401 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetGalaxies200ResponseInner>`")))),
402 }
403 } else {
404 let content = resp.text().await?;
405 let entity: Option<SearchGalaxiesError> = serde_json::from_str(&content).ok();
406 Err(Error::ResponseError(ResponseContent { status, content, entity }))
407 }
408}
409
410pub async fn update_galaxies(configuration: &configuration::Configuration, ) -> Result<models::UpdateGalaxies200Response, Error<UpdateGalaxiesError>> {
411
412 let uri_str = format!("{}/galaxies/update", configuration.base_path);
413 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
414
415 if let Some(ref user_agent) = configuration.user_agent {
416 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
417 }
418 if let Some(ref apikey) = configuration.api_key {
419 let key = apikey.key.clone();
420 let value = match apikey.prefix {
421 Some(ref prefix) => format!("{} {}", prefix, key),
422 None => key,
423 };
424 req_builder = req_builder.header("Authorization", value);
425 };
426
427 let req = req_builder.build()?;
428 let resp = configuration.client.execute(req).await?;
429
430 let status = resp.status();
431 let content_type = resp
432 .headers()
433 .get("content-type")
434 .and_then(|v| v.to_str().ok())
435 .unwrap_or("application/octet-stream");
436 let content_type = super::ContentType::from(content_type);
437
438 if !status.is_client_error() && !status.is_server_error() {
439 let content = resp.text().await?;
440 match content_type {
441 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateGalaxies200Response`"))),
443 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::UpdateGalaxies200Response`")))),
444 }
445 } else {
446 let content = resp.text().await?;
447 let entity: Option<UpdateGalaxiesError> = serde_json::from_str(&content).ok();
448 Err(Error::ResponseError(ResponseContent { status, content, entity }))
449 }
450}
451