misp_client_rs/apis/
galaxy_clusters_api.rs

1//!
2//! MISP Automation API
3//!
4//!  ### Getting Started  MISP API allows you to query, create, modify data models, such as [Events](https://www.circl.lu/doc/misp/GLOSSARY.html#misp-event), [Objects](https://www.circl.lu/doc/misp/misp-objects/), [Attributes](https://www.circl.lu/doc/misp/GLOSSARY.html#misp-attribute). This is extremly useful for interconnecting MISP with external tools and feeding other systems with threat intel data.  It also lets you perform administrative tasks such as creating users, organisations, altering MISP settings, and much more.  To get an API key there are several options: * **[UI]** Go to [My Profile -> Auth Keys](/auth_keys/index) section and click on `+ Add authentication key`  * **[UI]** As an admin go to the the [Administration -> List Users -> View](/admin/users/view/[id]) page of the user you want to create an auth key for and on the `Auth keys` section click on `+ Add authentication key`  * **[CLI]** Use the following command: `./app/Console/cake user change_authkey [e-mail/user_id]`  * **API** Provided you already have an admin level API key, you can create an API key for another user using the `[POST]/auth_keys/add/{{user_id}}` endpoint.  > **NOTE:** The authentication key will only be displayed once, so take note of it or store it properly in your application secrets.  #### Accept and Content-Type headers  When performing your request, depending on the type of request, you might need to explicitly specify in what content  type you want to get your results. This is done by setting one of the below `Accept` headers:      Accept: application/json     Accept: application/xml  When submitting data in a `POST`, `PUT` or `DELETE` operation you also need to specify in what content-type you encoded the payload.  This is done by setting one of the below `Content-Type` headers:      Content-Type: application/json     Content-Type: application/xml  Example: ``` curl  --header \"Authorization: YOUR_API_KEY\" \\       --header \"Accept: application/json\" \\       --header \"Content-Type: application/json\" https://<misp url>/  ```  > **NOTE**: By appending .json or .xml the content type can also be set without the need for a header.  #### Automation using PyMISP  [PyMISP](https://github.com/MISP/PyMISP) is a Python library to access MISP platforms via their REST [API](https://www.circl.lu/doc/misp/GLOSSARY.html#api). It allows you to fetch events, add or update events/attributes, add or update samples or search for attributes.  ### FAQ * [Dev FAQ](https://www.circl.lu/doc/misp/dev-faq/) * [GitHub project FAQ](https://github.com/MISP/MISP/wiki/Frequently-Asked-Questions) 
5//!
6//! The version of the OpenAPI document: 2.4
7//! 
8//! Generated by: https://openapi-generator.tech
9//! 
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`add_galaxy_cluster`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddGalaxyClusterError {
22    Status403(models::UnauthorizedApiError),
23    Status404(models::NotFoundApiError),
24    DefaultResponse(models::ApiError),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`delete_galaxy_cluster`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DeleteGalaxyClusterError {
32    Status403(models::UnauthorizedApiError),
33    Status404(models::NotFoundApiError),
34    DefaultResponse(models::ApiError),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`edit_galaxy_cluster`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum EditGalaxyClusterError {
42    Status403(models::UnauthorizedApiError),
43    Status404(models::NotFoundApiError),
44    DefaultResponse(models::ApiError),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_galaxy_cluster_by_id`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetGalaxyClusterByIdError {
52    Status403(models::UnauthorizedApiError),
53    Status404(models::NotFoundApiError),
54    DefaultResponse(models::ApiError),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`get_galaxy_clusters`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetGalaxyClustersError {
62    Status403(models::UnauthorizedApiError),
63    Status404(models::NotFoundApiError),
64    DefaultResponse(models::ApiError),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`publish_galaxy_cluster`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum PublishGalaxyClusterError {
72    Status403(models::UnauthorizedApiError),
73    Status404(models::NotFoundApiError),
74    DefaultResponse(models::ApiError),
75    UnknownValue(serde_json::Value),
76}
77
78/// struct for typed errors of method [`restore_galaxy_cluster`]
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum RestoreGalaxyClusterError {
82    Status403(models::UnauthorizedApiError),
83    Status404(models::NotFoundApiError),
84    DefaultResponse(models::ApiError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`search_galaxy_clusters`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum SearchGalaxyClustersError {
92    Status403(models::UnauthorizedApiError),
93    Status404(models::NotFoundApiError),
94    DefaultResponse(models::ApiError),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`unpublish_galaxy_cluster`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum UnpublishGalaxyClusterError {
102    Status403(models::UnauthorizedApiError),
103    Status404(models::NotFoundApiError),
104    DefaultResponse(models::ApiError),
105    UnknownValue(serde_json::Value),
106}
107
108
109pub async fn add_galaxy_cluster(configuration: &configuration::Configuration, galaxy_id: &str, galaxy_cluster: Option<models::GalaxyCluster>) -> Result<models::AddGalaxyCluster200Response, Error<AddGalaxyClusterError>> {
110    // add a prefix to parameters to efficiently prevent name collisions
111    let p_galaxy_id = galaxy_id;
112    let p_galaxy_cluster = galaxy_cluster;
113
114    let uri_str = format!("{}/galaxy_clusters/add/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
115    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
116
117    if let Some(ref user_agent) = configuration.user_agent {
118        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119    }
120    if let Some(ref apikey) = configuration.api_key {
121        let key = apikey.key.clone();
122        let value = match apikey.prefix {
123            Some(ref prefix) => format!("{} {}", prefix, key),
124            None => key,
125        };
126        req_builder = req_builder.header("Authorization", value);
127    };
128    req_builder = req_builder.json(&p_galaxy_cluster);
129
130    let req = req_builder.build()?;
131    let resp = configuration.client.execute(req).await?;
132
133    let status = resp.status();
134    let content_type = resp
135        .headers()
136        .get("content-type")
137        .and_then(|v| v.to_str().ok())
138        .unwrap_or("application/octet-stream");
139    let content_type = super::ContentType::from(content_type);
140
141    if !status.is_client_error() && !status.is_server_error() {
142        let content = resp.text().await?;
143        match content_type {
144            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
145            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddGalaxyCluster200Response`"))),
146            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::AddGalaxyCluster200Response`")))),
147        }
148    } else {
149        let content = resp.text().await?;
150        let entity: Option<AddGalaxyClusterError> = serde_json::from_str(&content).ok();
151        Err(Error::ResponseError(ResponseContent { status, content, entity }))
152    }
153}
154
155pub async fn delete_galaxy_cluster(configuration: &configuration::Configuration, galaxy_cluster_id: &str) -> Result<models::DeleteGalaxyCluster200Response, Error<DeleteGalaxyClusterError>> {
156    // add a prefix to parameters to efficiently prevent name collisions
157    let p_galaxy_cluster_id = galaxy_cluster_id;
158
159    let uri_str = format!("{}/galaxy_clusters/delete/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
160    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
161
162    if let Some(ref user_agent) = configuration.user_agent {
163        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164    }
165    if let Some(ref apikey) = configuration.api_key {
166        let key = apikey.key.clone();
167        let value = match apikey.prefix {
168            Some(ref prefix) => format!("{} {}", prefix, key),
169            None => key,
170        };
171        req_builder = req_builder.header("Authorization", value);
172    };
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteGalaxyCluster200Response`"))),
190            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::DeleteGalaxyCluster200Response`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<DeleteGalaxyClusterError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198
199pub async fn edit_galaxy_cluster(configuration: &configuration::Configuration, galaxy_cluster_id: &str, galaxy_cluster: Option<models::GalaxyCluster>) -> Result<models::AddGalaxyCluster200Response, Error<EditGalaxyClusterError>> {
200    // add a prefix to parameters to efficiently prevent name collisions
201    let p_galaxy_cluster_id = galaxy_cluster_id;
202    let p_galaxy_cluster = galaxy_cluster;
203
204    let uri_str = format!("{}/galaxy_clusters/edit/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
205    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
206
207    if let Some(ref user_agent) = configuration.user_agent {
208        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
209    }
210    if let Some(ref apikey) = configuration.api_key {
211        let key = apikey.key.clone();
212        let value = match apikey.prefix {
213            Some(ref prefix) => format!("{} {}", prefix, key),
214            None => key,
215        };
216        req_builder = req_builder.header("Authorization", value);
217    };
218    req_builder = req_builder.json(&p_galaxy_cluster);
219
220    let req = req_builder.build()?;
221    let resp = configuration.client.execute(req).await?;
222
223    let status = resp.status();
224    let content_type = resp
225        .headers()
226        .get("content-type")
227        .and_then(|v| v.to_str().ok())
228        .unwrap_or("application/octet-stream");
229    let content_type = super::ContentType::from(content_type);
230
231    if !status.is_client_error() && !status.is_server_error() {
232        let content = resp.text().await?;
233        match content_type {
234            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddGalaxyCluster200Response`"))),
236            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::AddGalaxyCluster200Response`")))),
237        }
238    } else {
239        let content = resp.text().await?;
240        let entity: Option<EditGalaxyClusterError> = serde_json::from_str(&content).ok();
241        Err(Error::ResponseError(ResponseContent { status, content, entity }))
242    }
243}
244
245pub async fn get_galaxy_cluster_by_id(configuration: &configuration::Configuration, galaxy_cluster_id: &str) -> Result<models::GetGalaxyClusterById200Response, Error<GetGalaxyClusterByIdError>> {
246    // add a prefix to parameters to efficiently prevent name collisions
247    let p_galaxy_cluster_id = galaxy_cluster_id;
248
249    let uri_str = format!("{}/galaxy_clusters/view/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
250    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
251
252    if let Some(ref user_agent) = configuration.user_agent {
253        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
254    }
255    if let Some(ref apikey) = configuration.api_key {
256        let key = apikey.key.clone();
257        let value = match apikey.prefix {
258            Some(ref prefix) => format!("{} {}", prefix, key),
259            None => key,
260        };
261        req_builder = req_builder.header("Authorization", value);
262    };
263
264    let req = req_builder.build()?;
265    let resp = configuration.client.execute(req).await?;
266
267    let status = resp.status();
268    let content_type = resp
269        .headers()
270        .get("content-type")
271        .and_then(|v| v.to_str().ok())
272        .unwrap_or("application/octet-stream");
273    let content_type = super::ContentType::from(content_type);
274
275    if !status.is_client_error() && !status.is_server_error() {
276        let content = resp.text().await?;
277        match content_type {
278            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
279            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGalaxyClusterById200Response`"))),
280            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::GetGalaxyClusterById200Response`")))),
281        }
282    } else {
283        let content = resp.text().await?;
284        let entity: Option<GetGalaxyClusterByIdError> = serde_json::from_str(&content).ok();
285        Err(Error::ResponseError(ResponseContent { status, content, entity }))
286    }
287}
288
289pub async fn get_galaxy_clusters(configuration: &configuration::Configuration, galaxy_id: &str) -> Result<Vec<models::AddGalaxyCluster200Response>, Error<GetGalaxyClustersError>> {
290    // add a prefix to parameters to efficiently prevent name collisions
291    let p_galaxy_id = galaxy_id;
292
293    let uri_str = format!("{}/galaxy_clusters/index/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
294    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
295
296    if let Some(ref user_agent) = configuration.user_agent {
297        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
298    }
299    if let Some(ref apikey) = configuration.api_key {
300        let key = apikey.key.clone();
301        let value = match apikey.prefix {
302            Some(ref prefix) => format!("{} {}", prefix, key),
303            None => key,
304        };
305        req_builder = req_builder.header("Authorization", value);
306    };
307
308    let req = req_builder.build()?;
309    let resp = configuration.client.execute(req).await?;
310
311    let status = resp.status();
312    let content_type = resp
313        .headers()
314        .get("content-type")
315        .and_then(|v| v.to_str().ok())
316        .unwrap_or("application/octet-stream");
317    let content_type = super::ContentType::from(content_type);
318
319    if !status.is_client_error() && !status.is_server_error() {
320        let content = resp.text().await?;
321        match content_type {
322            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
323            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::AddGalaxyCluster200Response&gt;`"))),
324            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&lt;models::AddGalaxyCluster200Response&gt;`")))),
325        }
326    } else {
327        let content = resp.text().await?;
328        let entity: Option<GetGalaxyClustersError> = serde_json::from_str(&content).ok();
329        Err(Error::ResponseError(ResponseContent { status, content, entity }))
330    }
331}
332
333pub async fn publish_galaxy_cluster(configuration: &configuration::Configuration, galaxy_cluster_id: &str) -> Result<models::PublishGalaxyCluster200Response, Error<PublishGalaxyClusterError>> {
334    // add a prefix to parameters to efficiently prevent name collisions
335    let p_galaxy_cluster_id = galaxy_cluster_id;
336
337    let uri_str = format!("{}/galaxy_clusters/publish/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
338    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
339
340    if let Some(ref user_agent) = configuration.user_agent {
341        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
342    }
343    if let Some(ref apikey) = configuration.api_key {
344        let key = apikey.key.clone();
345        let value = match apikey.prefix {
346            Some(ref prefix) => format!("{} {}", prefix, key),
347            None => key,
348        };
349        req_builder = req_builder.header("Authorization", value);
350    };
351
352    let req = req_builder.build()?;
353    let resp = configuration.client.execute(req).await?;
354
355    let status = resp.status();
356    let content_type = resp
357        .headers()
358        .get("content-type")
359        .and_then(|v| v.to_str().ok())
360        .unwrap_or("application/octet-stream");
361    let content_type = super::ContentType::from(content_type);
362
363    if !status.is_client_error() && !status.is_server_error() {
364        let content = resp.text().await?;
365        match content_type {
366            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PublishGalaxyCluster200Response`"))),
368            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::PublishGalaxyCluster200Response`")))),
369        }
370    } else {
371        let content = resp.text().await?;
372        let entity: Option<PublishGalaxyClusterError> = serde_json::from_str(&content).ok();
373        Err(Error::ResponseError(ResponseContent { status, content, entity }))
374    }
375}
376
377pub async fn restore_galaxy_cluster(configuration: &configuration::Configuration, galaxy_cluster_id: &str) -> Result<models::RestoreGalaxyCluster200Response, Error<RestoreGalaxyClusterError>> {
378    // add a prefix to parameters to efficiently prevent name collisions
379    let p_galaxy_cluster_id = galaxy_cluster_id;
380
381    let uri_str = format!("{}/galaxy_clusters/restore/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
382    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
383
384    if let Some(ref user_agent) = configuration.user_agent {
385        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
386    }
387    if let Some(ref apikey) = configuration.api_key {
388        let key = apikey.key.clone();
389        let value = match apikey.prefix {
390            Some(ref prefix) => format!("{} {}", prefix, key),
391            None => key,
392        };
393        req_builder = req_builder.header("Authorization", value);
394    };
395
396    let req = req_builder.build()?;
397    let resp = configuration.client.execute(req).await?;
398
399    let status = resp.status();
400    let content_type = resp
401        .headers()
402        .get("content-type")
403        .and_then(|v| v.to_str().ok())
404        .unwrap_or("application/octet-stream");
405    let content_type = super::ContentType::from(content_type);
406
407    if !status.is_client_error() && !status.is_server_error() {
408        let content = resp.text().await?;
409        match content_type {
410            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
411            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RestoreGalaxyCluster200Response`"))),
412            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::RestoreGalaxyCluster200Response`")))),
413        }
414    } else {
415        let content = resp.text().await?;
416        let entity: Option<RestoreGalaxyClusterError> = serde_json::from_str(&content).ok();
417        Err(Error::ResponseError(ResponseContent { status, content, entity }))
418    }
419}
420
421pub async fn search_galaxy_clusters(configuration: &configuration::Configuration, galaxy_id: &str, search_galaxy_clusters_request: Option<models::SearchGalaxyClustersRequest>) -> Result<Vec<models::AddGalaxyCluster200Response>, Error<SearchGalaxyClustersError>> {
422    // add a prefix to parameters to efficiently prevent name collisions
423    let p_galaxy_id = galaxy_id;
424    let p_search_galaxy_clusters_request = search_galaxy_clusters_request;
425
426    let uri_str = format!("{}/galaxy_clusters/index/{galaxyId}", configuration.base_path, galaxyId=p_galaxy_id.to_string());
427    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
428
429    if let Some(ref user_agent) = configuration.user_agent {
430        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
431    }
432    if let Some(ref apikey) = configuration.api_key {
433        let key = apikey.key.clone();
434        let value = match apikey.prefix {
435            Some(ref prefix) => format!("{} {}", prefix, key),
436            None => key,
437        };
438        req_builder = req_builder.header("Authorization", value);
439    };
440    req_builder = req_builder.json(&p_search_galaxy_clusters_request);
441
442    let req = req_builder.build()?;
443    let resp = configuration.client.execute(req).await?;
444
445    let status = resp.status();
446    let content_type = resp
447        .headers()
448        .get("content-type")
449        .and_then(|v| v.to_str().ok())
450        .unwrap_or("application/octet-stream");
451    let content_type = super::ContentType::from(content_type);
452
453    if !status.is_client_error() && !status.is_server_error() {
454        let content = resp.text().await?;
455        match content_type {
456            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
457            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::AddGalaxyCluster200Response&gt;`"))),
458            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&lt;models::AddGalaxyCluster200Response&gt;`")))),
459        }
460    } else {
461        let content = resp.text().await?;
462        let entity: Option<SearchGalaxyClustersError> = serde_json::from_str(&content).ok();
463        Err(Error::ResponseError(ResponseContent { status, content, entity }))
464    }
465}
466
467pub async fn unpublish_galaxy_cluster(configuration: &configuration::Configuration, galaxy_cluster_id: &str) -> Result<models::UnpublishGalaxyCluster200Response, Error<UnpublishGalaxyClusterError>> {
468    // add a prefix to parameters to efficiently prevent name collisions
469    let p_galaxy_cluster_id = galaxy_cluster_id;
470
471    let uri_str = format!("{}/galaxy_clusters/unpublish/{galaxyClusterId}", configuration.base_path, galaxyClusterId=p_galaxy_cluster_id.to_string());
472    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
473
474    if let Some(ref user_agent) = configuration.user_agent {
475        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
476    }
477    if let Some(ref apikey) = configuration.api_key {
478        let key = apikey.key.clone();
479        let value = match apikey.prefix {
480            Some(ref prefix) => format!("{} {}", prefix, key),
481            None => key,
482        };
483        req_builder = req_builder.header("Authorization", value);
484    };
485
486    let req = req_builder.build()?;
487    let resp = configuration.client.execute(req).await?;
488
489    let status = resp.status();
490    let content_type = resp
491        .headers()
492        .get("content-type")
493        .and_then(|v| v.to_str().ok())
494        .unwrap_or("application/octet-stream");
495    let content_type = super::ContentType::from(content_type);
496
497    if !status.is_client_error() && !status.is_server_error() {
498        let content = resp.text().await?;
499        match content_type {
500            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
501            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnpublishGalaxyCluster200Response`"))),
502            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::UnpublishGalaxyCluster200Response`")))),
503        }
504    } else {
505        let content = resp.text().await?;
506        let entity: Option<UnpublishGalaxyClusterError> = serde_json::from_str(&content).ok();
507        Err(Error::ResponseError(ResponseContent { status, content, entity }))
508    }
509}
510