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 AddEventError {
22 Status403(models::UnauthorizedApiError),
23 DefaultResponse(models::ApiError),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum DeleteEventError {
31 Status403(models::UnauthorizedApiError),
32 DefaultResponse(models::ApiError),
33 UnknownValue(serde_json::Value),
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum EditEventError {
40 Status403(models::UnauthorizedApiError),
41 DefaultResponse(models::ApiError),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum EnrichEventError {
49 Status403(models::UnauthorizedApiError),
50 DefaultResponse(models::ApiError),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetEventByIdError {
58 Status403(models::UnauthorizedApiError),
59 DefaultResponse(models::ApiError),
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetEventsError {
67 Status403(models::UnauthorizedApiError),
68 DefaultResponse(models::ApiError),
69 UnknownValue(serde_json::Value),
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum PublishEventError {
76 Status403(models::UnauthorizedApiError),
77 DefaultResponse(models::ApiError),
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RestSearchEventsError {
85 Status403(models::UnauthorizedApiError),
86 DefaultResponse(models::ApiError),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum SearchEventsError {
94 Status403(models::UnauthorizedApiError),
95 DefaultResponse(models::ApiError),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum TagEventError {
103 Status403(models::UnauthorizedApiError),
104 DefaultResponse(models::ApiError),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum UnpublishEventError {
112 Status403(models::UnauthorizedApiError),
113 DefaultResponse(models::ApiError),
114 UnknownValue(serde_json::Value),
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum UntagEventError {
121 Status403(models::UnauthorizedApiError),
122 DefaultResponse(models::ApiError),
123 UnknownValue(serde_json::Value),
124}
125
126
127pub async fn add_event(configuration: &configuration::Configuration, event_no_id: models::EventNoId) -> Result<models::EditedEvent, Error<AddEventError>> {
128 let p_event_no_id = event_no_id;
130
131 let uri_str = format!("{}/events/add", configuration.base_path);
132 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
133
134 if let Some(ref user_agent) = configuration.user_agent {
135 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
136 }
137 if let Some(ref apikey) = configuration.api_key {
138 let key = apikey.key.clone();
139 let value = match apikey.prefix {
140 Some(ref prefix) => format!("{} {}", prefix, key),
141 None => key,
142 };
143 req_builder = req_builder.header("Authorization", value);
144 };
145 req_builder = req_builder.json(&p_event_no_id);
146
147 let req = req_builder.build()?;
148 let resp = configuration.client.execute(req).await?;
149
150 let status = resp.status();
151 let content_type = resp
152 .headers()
153 .get("content-type")
154 .and_then(|v| v.to_str().ok())
155 .unwrap_or("application/octet-stream");
156 let content_type = super::ContentType::from(content_type);
157
158 if !status.is_client_error() && !status.is_server_error() {
159 let content = resp.text().await?;
160 match content_type {
161 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EditedEvent`"))),
163 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::EditedEvent`")))),
164 }
165 } else {
166 let content = resp.text().await?;
167 let entity: Option<AddEventError> = serde_json::from_str(&content).ok();
168 Err(Error::ResponseError(ResponseContent { status, content, entity }))
169 }
170}
171
172pub async fn delete_event(configuration: &configuration::Configuration, event_id: &str) -> Result<models::DeleteEvent200Response, Error<DeleteEventError>> {
173 let p_event_id = event_id;
175
176 let uri_str = format!("{}/events/delete/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
177 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
178
179 if let Some(ref user_agent) = configuration.user_agent {
180 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
181 }
182 if let Some(ref apikey) = configuration.api_key {
183 let key = apikey.key.clone();
184 let value = match apikey.prefix {
185 Some(ref prefix) => format!("{} {}", prefix, key),
186 None => key,
187 };
188 req_builder = req_builder.header("Authorization", value);
189 };
190
191 let req = req_builder.build()?;
192 let resp = configuration.client.execute(req).await?;
193
194 let status = resp.status();
195 let content_type = resp
196 .headers()
197 .get("content-type")
198 .and_then(|v| v.to_str().ok())
199 .unwrap_or("application/octet-stream");
200 let content_type = super::ContentType::from(content_type);
201
202 if !status.is_client_error() && !status.is_server_error() {
203 let content = resp.text().await?;
204 match content_type {
205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteEvent200Response`"))),
207 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::DeleteEvent200Response`")))),
208 }
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<DeleteEventError> = serde_json::from_str(&content).ok();
212 Err(Error::ResponseError(ResponseContent { status, content, entity }))
213 }
214}
215
216pub async fn edit_event(configuration: &configuration::Configuration, event_id: &str, event_no_id: models::EventNoId) -> Result<models::EditedEvent, Error<EditEventError>> {
217 let p_event_id = event_id;
219 let p_event_no_id = event_no_id;
220
221 let uri_str = format!("{}/events/edit/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
222 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
223
224 if let Some(ref user_agent) = configuration.user_agent {
225 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
226 }
227 if let Some(ref apikey) = configuration.api_key {
228 let key = apikey.key.clone();
229 let value = match apikey.prefix {
230 Some(ref prefix) => format!("{} {}", prefix, key),
231 None => key,
232 };
233 req_builder = req_builder.header("Authorization", value);
234 };
235 req_builder = req_builder.json(&p_event_no_id);
236
237 let req = req_builder.build()?;
238 let resp = configuration.client.execute(req).await?;
239
240 let status = resp.status();
241 let content_type = resp
242 .headers()
243 .get("content-type")
244 .and_then(|v| v.to_str().ok())
245 .unwrap_or("application/octet-stream");
246 let content_type = super::ContentType::from(content_type);
247
248 if !status.is_client_error() && !status.is_server_error() {
249 let content = resp.text().await?;
250 match content_type {
251 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
252 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EditedEvent`"))),
253 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::EditedEvent`")))),
254 }
255 } else {
256 let content = resp.text().await?;
257 let entity: Option<EditEventError> = serde_json::from_str(&content).ok();
258 Err(Error::ResponseError(ResponseContent { status, content, entity }))
259 }
260}
261
262pub async fn enrich_event(configuration: &configuration::Configuration, event_id: &str, enrich_modules_list: models::EnrichModulesList) -> Result<models::EnrichEvent200Response, Error<EnrichEventError>> {
263 let p_event_id = event_id;
265 let p_enrich_modules_list = enrich_modules_list;
266
267 let uri_str = format!("{}/events/enrichEvent/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
268 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
269
270 if let Some(ref user_agent) = configuration.user_agent {
271 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
272 }
273 if let Some(ref apikey) = configuration.api_key {
274 let key = apikey.key.clone();
275 let value = match apikey.prefix {
276 Some(ref prefix) => format!("{} {}", prefix, key),
277 None => key,
278 };
279 req_builder = req_builder.header("Authorization", value);
280 };
281 req_builder = req_builder.json(&p_enrich_modules_list);
282
283 let req = req_builder.build()?;
284 let resp = configuration.client.execute(req).await?;
285
286 let status = resp.status();
287 let content_type = resp
288 .headers()
289 .get("content-type")
290 .and_then(|v| v.to_str().ok())
291 .unwrap_or("application/octet-stream");
292 let content_type = super::ContentType::from(content_type);
293
294 if !status.is_client_error() && !status.is_server_error() {
295 let content = resp.text().await?;
296 match content_type {
297 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
298 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EnrichEvent200Response`"))),
299 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::EnrichEvent200Response`")))),
300 }
301 } else {
302 let content = resp.text().await?;
303 let entity: Option<EnrichEventError> = serde_json::from_str(&content).ok();
304 Err(Error::ResponseError(ResponseContent { status, content, entity }))
305 }
306}
307
308pub async fn get_event_by_id(configuration: &configuration::Configuration, event_id: &str) -> Result<models::GetEventById200Response, Error<GetEventByIdError>> {
309 let p_event_id = event_id;
311
312 let uri_str = format!("{}/events/view/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
313 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
314
315 if let Some(ref user_agent) = configuration.user_agent {
316 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317 }
318 if let Some(ref apikey) = configuration.api_key {
319 let key = apikey.key.clone();
320 let value = match apikey.prefix {
321 Some(ref prefix) => format!("{} {}", prefix, key),
322 None => key,
323 };
324 req_builder = req_builder.header("Authorization", value);
325 };
326
327 let req = req_builder.build()?;
328 let resp = configuration.client.execute(req).await?;
329
330 let status = resp.status();
331 let content_type = resp
332 .headers()
333 .get("content-type")
334 .and_then(|v| v.to_str().ok())
335 .unwrap_or("application/octet-stream");
336 let content_type = super::ContentType::from(content_type);
337
338 if !status.is_client_error() && !status.is_server_error() {
339 let content = resp.text().await?;
340 match content_type {
341 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
342 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEventById200Response`"))),
343 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::GetEventById200Response`")))),
344 }
345 } else {
346 let content = resp.text().await?;
347 let entity: Option<GetEventByIdError> = serde_json::from_str(&content).ok();
348 Err(Error::ResponseError(ResponseContent { status, content, entity }))
349 }
350}
351
352pub async fn get_events(configuration: &configuration::Configuration, ) -> Result<Vec<models::ExtendedEvent>, Error<GetEventsError>> {
353
354 let uri_str = format!("{}/events", configuration.base_path);
355 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
356
357 if let Some(ref user_agent) = configuration.user_agent {
358 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359 }
360 if let Some(ref apikey) = configuration.api_key {
361 let key = apikey.key.clone();
362 let value = match apikey.prefix {
363 Some(ref prefix) => format!("{} {}", prefix, key),
364 None => key,
365 };
366 req_builder = req_builder.header("Authorization", value);
367 };
368
369 let req = req_builder.build()?;
370 let resp = configuration.client.execute(req).await?;
371
372 let status = resp.status();
373 let content_type = resp
374 .headers()
375 .get("content-type")
376 .and_then(|v| v.to_str().ok())
377 .unwrap_or("application/octet-stream");
378 let content_type = super::ContentType::from(content_type);
379
380 if !status.is_client_error() && !status.is_server_error() {
381 let content = resp.text().await?;
382 match content_type {
383 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
384 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ExtendedEvent>`"))),
385 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::ExtendedEvent>`")))),
386 }
387 } else {
388 let content = resp.text().await?;
389 let entity: Option<GetEventsError> = serde_json::from_str(&content).ok();
390 Err(Error::ResponseError(ResponseContent { status, content, entity }))
391 }
392}
393
394pub async fn publish_event(configuration: &configuration::Configuration, event_id: &str) -> Result<models::PublishEvent200Response, Error<PublishEventError>> {
395 let p_event_id = event_id;
397
398 let uri_str = format!("{}/events/publish/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
399 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
400
401 if let Some(ref user_agent) = configuration.user_agent {
402 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
403 }
404 if let Some(ref apikey) = configuration.api_key {
405 let key = apikey.key.clone();
406 let value = match apikey.prefix {
407 Some(ref prefix) => format!("{} {}", prefix, key),
408 None => key,
409 };
410 req_builder = req_builder.header("Authorization", value);
411 };
412
413 let req = req_builder.build()?;
414 let resp = configuration.client.execute(req).await?;
415
416 let status = resp.status();
417 let content_type = resp
418 .headers()
419 .get("content-type")
420 .and_then(|v| v.to_str().ok())
421 .unwrap_or("application/octet-stream");
422 let content_type = super::ContentType::from(content_type);
423
424 if !status.is_client_error() && !status.is_server_error() {
425 let content = resp.text().await?;
426 match content_type {
427 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
428 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PublishEvent200Response`"))),
429 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::PublishEvent200Response`")))),
430 }
431 } else {
432 let content = resp.text().await?;
433 let entity: Option<PublishEventError> = serde_json::from_str(&content).ok();
434 Err(Error::ResponseError(ResponseContent { status, content, entity }))
435 }
436}
437
438pub async fn rest_search_events(configuration: &configuration::Configuration, rest_search_events_request: models::RestSearchEventsRequest) -> Result<models::RestSearchEvents200Response, Error<RestSearchEventsError>> {
440 let p_rest_search_events_request = rest_search_events_request;
442
443 let uri_str = format!("{}/events/restSearch", configuration.base_path);
444 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
445
446 if let Some(ref user_agent) = configuration.user_agent {
447 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
448 }
449 if let Some(ref apikey) = configuration.api_key {
450 let key = apikey.key.clone();
451 let value = match apikey.prefix {
452 Some(ref prefix) => format!("{} {}", prefix, key),
453 None => key,
454 };
455 req_builder = req_builder.header("Authorization", value);
456 };
457 req_builder = req_builder.json(&p_rest_search_events_request);
458
459 let req = req_builder.build()?;
460 let resp = configuration.client.execute(req).await?;
461
462 let status = resp.status();
463 let content_type = resp
464 .headers()
465 .get("content-type")
466 .and_then(|v| v.to_str().ok())
467 .unwrap_or("application/octet-stream");
468 let content_type = super::ContentType::from(content_type);
469
470 if !status.is_client_error() && !status.is_server_error() {
471 let content = resp.text().await?;
472 match content_type {
473 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
474 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RestSearchEvents200Response`"))),
475 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::RestSearchEvents200Response`")))),
476 }
477 } else {
478 let content = resp.text().await?;
479 let entity: Option<RestSearchEventsError> = serde_json::from_str(&content).ok();
480 Err(Error::ResponseError(ResponseContent { status, content, entity }))
481 }
482}
483
484pub async fn search_events(configuration: &configuration::Configuration, search_events_request: models::SearchEventsRequest) -> Result<Vec<models::ExtendedEvent>, Error<SearchEventsError>> {
485 let p_search_events_request = search_events_request;
487
488 let uri_str = format!("{}/events/index", configuration.base_path);
489 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
490
491 if let Some(ref user_agent) = configuration.user_agent {
492 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
493 }
494 if let Some(ref apikey) = configuration.api_key {
495 let key = apikey.key.clone();
496 let value = match apikey.prefix {
497 Some(ref prefix) => format!("{} {}", prefix, key),
498 None => key,
499 };
500 req_builder = req_builder.header("Authorization", value);
501 };
502 req_builder = req_builder.json(&p_search_events_request);
503
504 let req = req_builder.build()?;
505 let resp = configuration.client.execute(req).await?;
506
507 let status = resp.status();
508 let content_type = resp
509 .headers()
510 .get("content-type")
511 .and_then(|v| v.to_str().ok())
512 .unwrap_or("application/octet-stream");
513 let content_type = super::ContentType::from(content_type);
514
515 if !status.is_client_error() && !status.is_server_error() {
516 let content = resp.text().await?;
517 match content_type {
518 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ExtendedEvent>`"))),
520 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::ExtendedEvent>`")))),
521 }
522 } else {
523 let content = resp.text().await?;
524 let entity: Option<SearchEventsError> = serde_json::from_str(&content).ok();
525 Err(Error::ResponseError(ResponseContent { status, content, entity }))
526 }
527}
528
529pub async fn tag_event(configuration: &configuration::Configuration, event_id: &str, tag_id: &str, local: bool) -> Result<models::TagAttribute200Response, Error<TagEventError>> {
530 let p_event_id = event_id;
532 let p_tag_id = tag_id;
533 let p_local = local;
534
535 let uri_str = format!("{}/events/addTag/{eventId}/{tagId}/local:{local}", configuration.base_path, eventId=p_event_id.to_string(), tagId=crate::apis::urlencode(p_tag_id), local=p_local);
536 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
537
538 if let Some(ref user_agent) = configuration.user_agent {
539 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540 }
541 if let Some(ref apikey) = configuration.api_key {
542 let key = apikey.key.clone();
543 let value = match apikey.prefix {
544 Some(ref prefix) => format!("{} {}", prefix, key),
545 None => key,
546 };
547 req_builder = req_builder.header("Authorization", value);
548 };
549
550 let req = req_builder.build()?;
551 let resp = configuration.client.execute(req).await?;
552
553 let status = resp.status();
554 let content_type = resp
555 .headers()
556 .get("content-type")
557 .and_then(|v| v.to_str().ok())
558 .unwrap_or("application/octet-stream");
559 let content_type = super::ContentType::from(content_type);
560
561 if !status.is_client_error() && !status.is_server_error() {
562 let content = resp.text().await?;
563 match content_type {
564 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
565 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TagAttribute200Response`"))),
566 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::TagAttribute200Response`")))),
567 }
568 } else {
569 let content = resp.text().await?;
570 let entity: Option<TagEventError> = serde_json::from_str(&content).ok();
571 Err(Error::ResponseError(ResponseContent { status, content, entity }))
572 }
573}
574
575pub async fn unpublish_event(configuration: &configuration::Configuration, event_id: &str) -> Result<models::UnpublishEvent200Response, Error<UnpublishEventError>> {
576 let p_event_id = event_id;
578
579 let uri_str = format!("{}/events/unpublish/{eventId}", configuration.base_path, eventId=p_event_id.to_string());
580 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
581
582 if let Some(ref user_agent) = configuration.user_agent {
583 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
584 }
585 if let Some(ref apikey) = configuration.api_key {
586 let key = apikey.key.clone();
587 let value = match apikey.prefix {
588 Some(ref prefix) => format!("{} {}", prefix, key),
589 None => key,
590 };
591 req_builder = req_builder.header("Authorization", value);
592 };
593
594 let req = req_builder.build()?;
595 let resp = configuration.client.execute(req).await?;
596
597 let status = resp.status();
598 let content_type = resp
599 .headers()
600 .get("content-type")
601 .and_then(|v| v.to_str().ok())
602 .unwrap_or("application/octet-stream");
603 let content_type = super::ContentType::from(content_type);
604
605 if !status.is_client_error() && !status.is_server_error() {
606 let content = resp.text().await?;
607 match content_type {
608 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
609 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnpublishEvent200Response`"))),
610 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::UnpublishEvent200Response`")))),
611 }
612 } else {
613 let content = resp.text().await?;
614 let entity: Option<UnpublishEventError> = serde_json::from_str(&content).ok();
615 Err(Error::ResponseError(ResponseContent { status, content, entity }))
616 }
617}
618
619pub async fn untag_event(configuration: &configuration::Configuration, event_id: &str, tag_id: &str) -> Result<models::UntagAttribute200Response, Error<UntagEventError>> {
620 let p_event_id = event_id;
622 let p_tag_id = tag_id;
623
624 let uri_str = format!("{}/events/removeTag/{eventId}/{tagId}", configuration.base_path, eventId=p_event_id.to_string(), tagId=crate::apis::urlencode(p_tag_id));
625 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
626
627 if let Some(ref user_agent) = configuration.user_agent {
628 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
629 }
630 if let Some(ref apikey) = configuration.api_key {
631 let key = apikey.key.clone();
632 let value = match apikey.prefix {
633 Some(ref prefix) => format!("{} {}", prefix, key),
634 None => key,
635 };
636 req_builder = req_builder.header("Authorization", value);
637 };
638
639 let req = req_builder.build()?;
640 let resp = configuration.client.execute(req).await?;
641
642 let status = resp.status();
643 let content_type = resp
644 .headers()
645 .get("content-type")
646 .and_then(|v| v.to_str().ok())
647 .unwrap_or("application/octet-stream");
648 let content_type = super::ContentType::from(content_type);
649
650 if !status.is_client_error() && !status.is_server_error() {
651 let content = resp.text().await?;
652 match content_type {
653 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
654 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UntagAttribute200Response`"))),
655 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::UntagAttribute200Response`")))),
656 }
657 } else {
658 let content = resp.text().await?;
659 let entity: Option<UntagEventError> = serde_json::from_str(&content).ok();
660 Err(Error::ResponseError(ResponseContent { status, content, entity }))
661 }
662}
663