1use crate::datadog;
5use flate2::{
6 write::{GzEncoder, ZlibEncoder},
7 Compression,
8};
9use reqwest::header::{HeaderMap, HeaderValue};
10use serde::{Deserialize, Serialize};
11use std::io::Write;
12
13#[non_exhaustive]
15#[derive(Clone, Default, Debug)]
16pub struct ListTenantBasedHandlesOptionalParams {
17 pub tenant_id: Option<String>,
19 pub name: Option<String>,
21}
22
23impl ListTenantBasedHandlesOptionalParams {
24 pub fn tenant_id(mut self, value: String) -> Self {
26 self.tenant_id = Some(value);
27 self
28 }
29 pub fn name(mut self, value: String) -> Self {
31 self.name = Some(value);
32 self
33 }
34}
35
36#[non_exhaustive]
38#[derive(Clone, Default, Debug)]
39pub struct ListWorkflowsWebhookHandlesOptionalParams {
40 pub name: Option<String>,
42}
43
44impl ListWorkflowsWebhookHandlesOptionalParams {
45 pub fn name(mut self, value: String) -> Self {
47 self.name = Some(value);
48 self
49 }
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum CreateTenantBasedHandleError {
56 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum CreateWorkflowsWebhookHandleError {
64 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum DeleteTenantBasedHandleError {
72 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum DeleteWorkflowsWebhookHandleError {
80 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetChannelByNameError {
88 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum GetTenantBasedHandleError {
96 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum GetWorkflowsWebhookHandleError {
104 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum ListTenantBasedHandlesError {
112 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ListWorkflowsWebhookHandlesError {
120 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
121 UnknownValue(serde_json::Value),
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum UpdateTenantBasedHandleError {
128 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
129 UnknownValue(serde_json::Value),
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum UpdateWorkflowsWebhookHandleError {
136 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
137 UnknownValue(serde_json::Value),
138}
139
140#[derive(Debug, Clone)]
143pub struct MicrosoftTeamsIntegrationAPI {
144 config: datadog::Configuration,
145 client: reqwest_middleware::ClientWithMiddleware,
146}
147
148impl Default for MicrosoftTeamsIntegrationAPI {
149 fn default() -> Self {
150 Self::with_config(datadog::Configuration::default())
151 }
152}
153
154impl MicrosoftTeamsIntegrationAPI {
155 pub fn new() -> Self {
156 Self::default()
157 }
158 pub fn with_config(config: datadog::Configuration) -> Self {
159 let mut reqwest_client_builder = reqwest::Client::builder();
160
161 if let Some(proxy_url) = &config.proxy_url {
162 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
163 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
164 }
165
166 let mut middleware_client_builder =
167 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
168
169 if config.enable_retry {
170 struct RetryableStatus;
171 impl reqwest_retry::RetryableStrategy for RetryableStatus {
172 fn handle(
173 &self,
174 res: &Result<reqwest::Response, reqwest_middleware::Error>,
175 ) -> Option<reqwest_retry::Retryable> {
176 match res {
177 Ok(success) => reqwest_retry::default_on_request_success(success),
178 Err(_) => None,
179 }
180 }
181 }
182 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
183 .build_with_max_retries(config.max_retries);
184
185 let retry_middleware =
186 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
187 backoff_policy,
188 RetryableStatus,
189 );
190
191 middleware_client_builder = middleware_client_builder.with(retry_middleware);
192 }
193
194 let client = middleware_client_builder.build();
195
196 Self { config, client }
197 }
198
199 pub fn with_client_and_config(
200 config: datadog::Configuration,
201 client: reqwest_middleware::ClientWithMiddleware,
202 ) -> Self {
203 Self { config, client }
204 }
205
206 pub async fn create_tenant_based_handle(
208 &self,
209 body: crate::datadogV2::model::MicrosoftTeamsCreateTenantBasedHandleRequest,
210 ) -> Result<
211 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
212 datadog::Error<CreateTenantBasedHandleError>,
213 > {
214 match self.create_tenant_based_handle_with_http_info(body).await {
215 Ok(response_content) => {
216 if let Some(e) = response_content.entity {
217 Ok(e)
218 } else {
219 Err(datadog::Error::Serde(serde::de::Error::custom(
220 "response content was None",
221 )))
222 }
223 }
224 Err(err) => Err(err),
225 }
226 }
227
228 pub async fn create_tenant_based_handle_with_http_info(
230 &self,
231 body: crate::datadogV2::model::MicrosoftTeamsCreateTenantBasedHandleRequest,
232 ) -> Result<
233 datadog::ResponseContent<crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse>,
234 datadog::Error<CreateTenantBasedHandleError>,
235 > {
236 let local_configuration = &self.config;
237 let operation_id = "v2.create_tenant_based_handle";
238
239 let local_client = &self.client;
240
241 let local_uri_str = format!(
242 "{}/api/v2/integration/ms-teams/configuration/tenant-based-handles",
243 local_configuration.get_operation_host(operation_id)
244 );
245 let mut local_req_builder =
246 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
247
248 let mut headers = HeaderMap::new();
250 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
251 headers.insert("Accept", HeaderValue::from_static("application/json"));
252
253 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
255 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
256 Err(e) => {
257 log::warn!("Failed to parse user agent header: {e}, falling back to default");
258 headers.insert(
259 reqwest::header::USER_AGENT,
260 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
261 )
262 }
263 };
264
265 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
267 headers.insert(
268 "DD-API-KEY",
269 HeaderValue::from_str(local_key.key.as_str())
270 .expect("failed to parse DD-API-KEY header"),
271 );
272 };
273 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
274 headers.insert(
275 "DD-APPLICATION-KEY",
276 HeaderValue::from_str(local_key.key.as_str())
277 .expect("failed to parse DD-APPLICATION-KEY header"),
278 );
279 };
280
281 let output = Vec::new();
283 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
284 if body.serialize(&mut ser).is_ok() {
285 if let Some(content_encoding) = headers.get("Content-Encoding") {
286 match content_encoding.to_str().unwrap_or_default() {
287 "gzip" => {
288 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
289 let _ = enc.write_all(ser.into_inner().as_slice());
290 match enc.finish() {
291 Ok(buf) => {
292 local_req_builder = local_req_builder.body(buf);
293 }
294 Err(e) => return Err(datadog::Error::Io(e)),
295 }
296 }
297 "deflate" => {
298 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
299 let _ = enc.write_all(ser.into_inner().as_slice());
300 match enc.finish() {
301 Ok(buf) => {
302 local_req_builder = local_req_builder.body(buf);
303 }
304 Err(e) => return Err(datadog::Error::Io(e)),
305 }
306 }
307 "zstd1" => {
308 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
309 let _ = enc.write_all(ser.into_inner().as_slice());
310 match enc.finish() {
311 Ok(buf) => {
312 local_req_builder = local_req_builder.body(buf);
313 }
314 Err(e) => return Err(datadog::Error::Io(e)),
315 }
316 }
317 _ => {
318 local_req_builder = local_req_builder.body(ser.into_inner());
319 }
320 }
321 } else {
322 local_req_builder = local_req_builder.body(ser.into_inner());
323 }
324 }
325
326 local_req_builder = local_req_builder.headers(headers);
327 let local_req = local_req_builder.build()?;
328 log::debug!("request content: {:?}", local_req.body());
329 let local_resp = local_client.execute(local_req).await?;
330
331 let local_status = local_resp.status();
332 let local_content = local_resp.text().await?;
333 log::debug!("response content: {}", local_content);
334
335 if !local_status.is_client_error() && !local_status.is_server_error() {
336 match serde_json::from_str::<
337 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
338 >(&local_content)
339 {
340 Ok(e) => {
341 return Ok(datadog::ResponseContent {
342 status: local_status,
343 content: local_content,
344 entity: Some(e),
345 })
346 }
347 Err(e) => return Err(datadog::Error::Serde(e)),
348 };
349 } else {
350 let local_entity: Option<CreateTenantBasedHandleError> =
351 serde_json::from_str(&local_content).ok();
352 let local_error = datadog::ResponseContent {
353 status: local_status,
354 content: local_content,
355 entity: local_entity,
356 };
357 Err(datadog::Error::ResponseError(local_error))
358 }
359 }
360
361 pub async fn create_workflows_webhook_handle(
363 &self,
364 body: crate::datadogV2::model::MicrosoftTeamsCreateWorkflowsWebhookHandleRequest,
365 ) -> Result<
366 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
367 datadog::Error<CreateWorkflowsWebhookHandleError>,
368 > {
369 match self
370 .create_workflows_webhook_handle_with_http_info(body)
371 .await
372 {
373 Ok(response_content) => {
374 if let Some(e) = response_content.entity {
375 Ok(e)
376 } else {
377 Err(datadog::Error::Serde(serde::de::Error::custom(
378 "response content was None",
379 )))
380 }
381 }
382 Err(err) => Err(err),
383 }
384 }
385
386 pub async fn create_workflows_webhook_handle_with_http_info(
388 &self,
389 body: crate::datadogV2::model::MicrosoftTeamsCreateWorkflowsWebhookHandleRequest,
390 ) -> Result<
391 datadog::ResponseContent<
392 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
393 >,
394 datadog::Error<CreateWorkflowsWebhookHandleError>,
395 > {
396 let local_configuration = &self.config;
397 let operation_id = "v2.create_workflows_webhook_handle";
398
399 let local_client = &self.client;
400
401 let local_uri_str = format!(
402 "{}/api/v2/integration/ms-teams/configuration/workflows-webhook-handles",
403 local_configuration.get_operation_host(operation_id)
404 );
405 let mut local_req_builder =
406 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
407
408 let mut headers = HeaderMap::new();
410 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
411 headers.insert("Accept", HeaderValue::from_static("application/json"));
412
413 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
415 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
416 Err(e) => {
417 log::warn!("Failed to parse user agent header: {e}, falling back to default");
418 headers.insert(
419 reqwest::header::USER_AGENT,
420 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
421 )
422 }
423 };
424
425 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
427 headers.insert(
428 "DD-API-KEY",
429 HeaderValue::from_str(local_key.key.as_str())
430 .expect("failed to parse DD-API-KEY header"),
431 );
432 };
433 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
434 headers.insert(
435 "DD-APPLICATION-KEY",
436 HeaderValue::from_str(local_key.key.as_str())
437 .expect("failed to parse DD-APPLICATION-KEY header"),
438 );
439 };
440
441 let output = Vec::new();
443 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
444 if body.serialize(&mut ser).is_ok() {
445 if let Some(content_encoding) = headers.get("Content-Encoding") {
446 match content_encoding.to_str().unwrap_or_default() {
447 "gzip" => {
448 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
449 let _ = enc.write_all(ser.into_inner().as_slice());
450 match enc.finish() {
451 Ok(buf) => {
452 local_req_builder = local_req_builder.body(buf);
453 }
454 Err(e) => return Err(datadog::Error::Io(e)),
455 }
456 }
457 "deflate" => {
458 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
459 let _ = enc.write_all(ser.into_inner().as_slice());
460 match enc.finish() {
461 Ok(buf) => {
462 local_req_builder = local_req_builder.body(buf);
463 }
464 Err(e) => return Err(datadog::Error::Io(e)),
465 }
466 }
467 "zstd1" => {
468 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
469 let _ = enc.write_all(ser.into_inner().as_slice());
470 match enc.finish() {
471 Ok(buf) => {
472 local_req_builder = local_req_builder.body(buf);
473 }
474 Err(e) => return Err(datadog::Error::Io(e)),
475 }
476 }
477 _ => {
478 local_req_builder = local_req_builder.body(ser.into_inner());
479 }
480 }
481 } else {
482 local_req_builder = local_req_builder.body(ser.into_inner());
483 }
484 }
485
486 local_req_builder = local_req_builder.headers(headers);
487 let local_req = local_req_builder.build()?;
488 log::debug!("request content: {:?}", local_req.body());
489 let local_resp = local_client.execute(local_req).await?;
490
491 let local_status = local_resp.status();
492 let local_content = local_resp.text().await?;
493 log::debug!("response content: {}", local_content);
494
495 if !local_status.is_client_error() && !local_status.is_server_error() {
496 match serde_json::from_str::<
497 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
498 >(&local_content)
499 {
500 Ok(e) => {
501 return Ok(datadog::ResponseContent {
502 status: local_status,
503 content: local_content,
504 entity: Some(e),
505 })
506 }
507 Err(e) => return Err(datadog::Error::Serde(e)),
508 };
509 } else {
510 let local_entity: Option<CreateWorkflowsWebhookHandleError> =
511 serde_json::from_str(&local_content).ok();
512 let local_error = datadog::ResponseContent {
513 status: local_status,
514 content: local_content,
515 entity: local_entity,
516 };
517 Err(datadog::Error::ResponseError(local_error))
518 }
519 }
520
521 pub async fn delete_tenant_based_handle(
523 &self,
524 handle_id: String,
525 ) -> Result<(), datadog::Error<DeleteTenantBasedHandleError>> {
526 match self
527 .delete_tenant_based_handle_with_http_info(handle_id)
528 .await
529 {
530 Ok(_) => Ok(()),
531 Err(err) => Err(err),
532 }
533 }
534
535 pub async fn delete_tenant_based_handle_with_http_info(
537 &self,
538 handle_id: String,
539 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteTenantBasedHandleError>> {
540 let local_configuration = &self.config;
541 let operation_id = "v2.delete_tenant_based_handle";
542
543 let local_client = &self.client;
544
545 let local_uri_str = format!(
546 "{}/api/v2/integration/ms-teams/configuration/tenant-based-handles/{handle_id}",
547 local_configuration.get_operation_host(operation_id),
548 handle_id = datadog::urlencode(handle_id)
549 );
550 let mut local_req_builder =
551 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
552
553 let mut headers = HeaderMap::new();
555 headers.insert("Accept", HeaderValue::from_static("*/*"));
556
557 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
559 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
560 Err(e) => {
561 log::warn!("Failed to parse user agent header: {e}, falling back to default");
562 headers.insert(
563 reqwest::header::USER_AGENT,
564 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
565 )
566 }
567 };
568
569 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
571 headers.insert(
572 "DD-API-KEY",
573 HeaderValue::from_str(local_key.key.as_str())
574 .expect("failed to parse DD-API-KEY header"),
575 );
576 };
577 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
578 headers.insert(
579 "DD-APPLICATION-KEY",
580 HeaderValue::from_str(local_key.key.as_str())
581 .expect("failed to parse DD-APPLICATION-KEY header"),
582 );
583 };
584
585 local_req_builder = local_req_builder.headers(headers);
586 let local_req = local_req_builder.build()?;
587 log::debug!("request content: {:?}", local_req.body());
588 let local_resp = local_client.execute(local_req).await?;
589
590 let local_status = local_resp.status();
591 let local_content = local_resp.text().await?;
592 log::debug!("response content: {}", local_content);
593
594 if !local_status.is_client_error() && !local_status.is_server_error() {
595 Ok(datadog::ResponseContent {
596 status: local_status,
597 content: local_content,
598 entity: None,
599 })
600 } else {
601 let local_entity: Option<DeleteTenantBasedHandleError> =
602 serde_json::from_str(&local_content).ok();
603 let local_error = datadog::ResponseContent {
604 status: local_status,
605 content: local_content,
606 entity: local_entity,
607 };
608 Err(datadog::Error::ResponseError(local_error))
609 }
610 }
611
612 pub async fn delete_workflows_webhook_handle(
614 &self,
615 handle_id: String,
616 ) -> Result<(), datadog::Error<DeleteWorkflowsWebhookHandleError>> {
617 match self
618 .delete_workflows_webhook_handle_with_http_info(handle_id)
619 .await
620 {
621 Ok(_) => Ok(()),
622 Err(err) => Err(err),
623 }
624 }
625
626 pub async fn delete_workflows_webhook_handle_with_http_info(
628 &self,
629 handle_id: String,
630 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteWorkflowsWebhookHandleError>>
631 {
632 let local_configuration = &self.config;
633 let operation_id = "v2.delete_workflows_webhook_handle";
634
635 let local_client = &self.client;
636
637 let local_uri_str = format!(
638 "{}/api/v2/integration/ms-teams/configuration/workflows-webhook-handles/{handle_id}",
639 local_configuration.get_operation_host(operation_id),
640 handle_id = datadog::urlencode(handle_id)
641 );
642 let mut local_req_builder =
643 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
644
645 let mut headers = HeaderMap::new();
647 headers.insert("Accept", HeaderValue::from_static("*/*"));
648
649 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
651 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
652 Err(e) => {
653 log::warn!("Failed to parse user agent header: {e}, falling back to default");
654 headers.insert(
655 reqwest::header::USER_AGENT,
656 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
657 )
658 }
659 };
660
661 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
663 headers.insert(
664 "DD-API-KEY",
665 HeaderValue::from_str(local_key.key.as_str())
666 .expect("failed to parse DD-API-KEY header"),
667 );
668 };
669 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
670 headers.insert(
671 "DD-APPLICATION-KEY",
672 HeaderValue::from_str(local_key.key.as_str())
673 .expect("failed to parse DD-APPLICATION-KEY header"),
674 );
675 };
676
677 local_req_builder = local_req_builder.headers(headers);
678 let local_req = local_req_builder.build()?;
679 log::debug!("request content: {:?}", local_req.body());
680 let local_resp = local_client.execute(local_req).await?;
681
682 let local_status = local_resp.status();
683 let local_content = local_resp.text().await?;
684 log::debug!("response content: {}", local_content);
685
686 if !local_status.is_client_error() && !local_status.is_server_error() {
687 Ok(datadog::ResponseContent {
688 status: local_status,
689 content: local_content,
690 entity: None,
691 })
692 } else {
693 let local_entity: Option<DeleteWorkflowsWebhookHandleError> =
694 serde_json::from_str(&local_content).ok();
695 let local_error = datadog::ResponseContent {
696 status: local_status,
697 content: local_content,
698 entity: local_entity,
699 };
700 Err(datadog::Error::ResponseError(local_error))
701 }
702 }
703
704 pub async fn get_channel_by_name(
706 &self,
707 tenant_name: String,
708 team_name: String,
709 channel_name: String,
710 ) -> Result<
711 crate::datadogV2::model::MicrosoftTeamsGetChannelByNameResponse,
712 datadog::Error<GetChannelByNameError>,
713 > {
714 match self
715 .get_channel_by_name_with_http_info(tenant_name, team_name, channel_name)
716 .await
717 {
718 Ok(response_content) => {
719 if let Some(e) = response_content.entity {
720 Ok(e)
721 } else {
722 Err(datadog::Error::Serde(serde::de::Error::custom(
723 "response content was None",
724 )))
725 }
726 }
727 Err(err) => Err(err),
728 }
729 }
730
731 pub async fn get_channel_by_name_with_http_info(
733 &self,
734 tenant_name: String,
735 team_name: String,
736 channel_name: String,
737 ) -> Result<
738 datadog::ResponseContent<crate::datadogV2::model::MicrosoftTeamsGetChannelByNameResponse>,
739 datadog::Error<GetChannelByNameError>,
740 > {
741 let local_configuration = &self.config;
742 let operation_id = "v2.get_channel_by_name";
743
744 let local_client = &self.client;
745
746 let local_uri_str = format!(
747 "{}/api/v2/integration/ms-teams/configuration/channel/{tenant_name}/{team_name}/{channel_name}",
748 local_configuration.get_operation_host(operation_id), tenant_name=
749 datadog::urlencode(tenant_name)
750 , team_name=
751 datadog::urlencode(team_name)
752 , channel_name=
753 datadog::urlencode(channel_name)
754 );
755 let mut local_req_builder =
756 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
757
758 let mut headers = HeaderMap::new();
760 headers.insert("Accept", HeaderValue::from_static("application/json"));
761
762 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
764 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
765 Err(e) => {
766 log::warn!("Failed to parse user agent header: {e}, falling back to default");
767 headers.insert(
768 reqwest::header::USER_AGENT,
769 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
770 )
771 }
772 };
773
774 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
776 headers.insert(
777 "DD-API-KEY",
778 HeaderValue::from_str(local_key.key.as_str())
779 .expect("failed to parse DD-API-KEY header"),
780 );
781 };
782 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
783 headers.insert(
784 "DD-APPLICATION-KEY",
785 HeaderValue::from_str(local_key.key.as_str())
786 .expect("failed to parse DD-APPLICATION-KEY header"),
787 );
788 };
789
790 local_req_builder = local_req_builder.headers(headers);
791 let local_req = local_req_builder.build()?;
792 log::debug!("request content: {:?}", local_req.body());
793 let local_resp = local_client.execute(local_req).await?;
794
795 let local_status = local_resp.status();
796 let local_content = local_resp.text().await?;
797 log::debug!("response content: {}", local_content);
798
799 if !local_status.is_client_error() && !local_status.is_server_error() {
800 match serde_json::from_str::<
801 crate::datadogV2::model::MicrosoftTeamsGetChannelByNameResponse,
802 >(&local_content)
803 {
804 Ok(e) => {
805 return Ok(datadog::ResponseContent {
806 status: local_status,
807 content: local_content,
808 entity: Some(e),
809 })
810 }
811 Err(e) => return Err(datadog::Error::Serde(e)),
812 };
813 } else {
814 let local_entity: Option<GetChannelByNameError> =
815 serde_json::from_str(&local_content).ok();
816 let local_error = datadog::ResponseContent {
817 status: local_status,
818 content: local_content,
819 entity: local_entity,
820 };
821 Err(datadog::Error::ResponseError(local_error))
822 }
823 }
824
825 pub async fn get_tenant_based_handle(
827 &self,
828 handle_id: String,
829 ) -> Result<
830 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
831 datadog::Error<GetTenantBasedHandleError>,
832 > {
833 match self.get_tenant_based_handle_with_http_info(handle_id).await {
834 Ok(response_content) => {
835 if let Some(e) = response_content.entity {
836 Ok(e)
837 } else {
838 Err(datadog::Error::Serde(serde::de::Error::custom(
839 "response content was None",
840 )))
841 }
842 }
843 Err(err) => Err(err),
844 }
845 }
846
847 pub async fn get_tenant_based_handle_with_http_info(
849 &self,
850 handle_id: String,
851 ) -> Result<
852 datadog::ResponseContent<crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse>,
853 datadog::Error<GetTenantBasedHandleError>,
854 > {
855 let local_configuration = &self.config;
856 let operation_id = "v2.get_tenant_based_handle";
857
858 let local_client = &self.client;
859
860 let local_uri_str = format!(
861 "{}/api/v2/integration/ms-teams/configuration/tenant-based-handles/{handle_id}",
862 local_configuration.get_operation_host(operation_id),
863 handle_id = datadog::urlencode(handle_id)
864 );
865 let mut local_req_builder =
866 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
867
868 let mut headers = HeaderMap::new();
870 headers.insert("Accept", HeaderValue::from_static("application/json"));
871
872 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
874 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
875 Err(e) => {
876 log::warn!("Failed to parse user agent header: {e}, falling back to default");
877 headers.insert(
878 reqwest::header::USER_AGENT,
879 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
880 )
881 }
882 };
883
884 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
886 headers.insert(
887 "DD-API-KEY",
888 HeaderValue::from_str(local_key.key.as_str())
889 .expect("failed to parse DD-API-KEY header"),
890 );
891 };
892 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
893 headers.insert(
894 "DD-APPLICATION-KEY",
895 HeaderValue::from_str(local_key.key.as_str())
896 .expect("failed to parse DD-APPLICATION-KEY header"),
897 );
898 };
899
900 local_req_builder = local_req_builder.headers(headers);
901 let local_req = local_req_builder.build()?;
902 log::debug!("request content: {:?}", local_req.body());
903 let local_resp = local_client.execute(local_req).await?;
904
905 let local_status = local_resp.status();
906 let local_content = local_resp.text().await?;
907 log::debug!("response content: {}", local_content);
908
909 if !local_status.is_client_error() && !local_status.is_server_error() {
910 match serde_json::from_str::<
911 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
912 >(&local_content)
913 {
914 Ok(e) => {
915 return Ok(datadog::ResponseContent {
916 status: local_status,
917 content: local_content,
918 entity: Some(e),
919 })
920 }
921 Err(e) => return Err(datadog::Error::Serde(e)),
922 };
923 } else {
924 let local_entity: Option<GetTenantBasedHandleError> =
925 serde_json::from_str(&local_content).ok();
926 let local_error = datadog::ResponseContent {
927 status: local_status,
928 content: local_content,
929 entity: local_entity,
930 };
931 Err(datadog::Error::ResponseError(local_error))
932 }
933 }
934
935 pub async fn get_workflows_webhook_handle(
937 &self,
938 handle_id: String,
939 ) -> Result<
940 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
941 datadog::Error<GetWorkflowsWebhookHandleError>,
942 > {
943 match self
944 .get_workflows_webhook_handle_with_http_info(handle_id)
945 .await
946 {
947 Ok(response_content) => {
948 if let Some(e) = response_content.entity {
949 Ok(e)
950 } else {
951 Err(datadog::Error::Serde(serde::de::Error::custom(
952 "response content was None",
953 )))
954 }
955 }
956 Err(err) => Err(err),
957 }
958 }
959
960 pub async fn get_workflows_webhook_handle_with_http_info(
962 &self,
963 handle_id: String,
964 ) -> Result<
965 datadog::ResponseContent<
966 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
967 >,
968 datadog::Error<GetWorkflowsWebhookHandleError>,
969 > {
970 let local_configuration = &self.config;
971 let operation_id = "v2.get_workflows_webhook_handle";
972
973 let local_client = &self.client;
974
975 let local_uri_str = format!(
976 "{}/api/v2/integration/ms-teams/configuration/workflows-webhook-handles/{handle_id}",
977 local_configuration.get_operation_host(operation_id),
978 handle_id = datadog::urlencode(handle_id)
979 );
980 let mut local_req_builder =
981 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
982
983 let mut headers = HeaderMap::new();
985 headers.insert("Accept", HeaderValue::from_static("application/json"));
986
987 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
989 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
990 Err(e) => {
991 log::warn!("Failed to parse user agent header: {e}, falling back to default");
992 headers.insert(
993 reqwest::header::USER_AGENT,
994 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
995 )
996 }
997 };
998
999 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1001 headers.insert(
1002 "DD-API-KEY",
1003 HeaderValue::from_str(local_key.key.as_str())
1004 .expect("failed to parse DD-API-KEY header"),
1005 );
1006 };
1007 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1008 headers.insert(
1009 "DD-APPLICATION-KEY",
1010 HeaderValue::from_str(local_key.key.as_str())
1011 .expect("failed to parse DD-APPLICATION-KEY header"),
1012 );
1013 };
1014
1015 local_req_builder = local_req_builder.headers(headers);
1016 let local_req = local_req_builder.build()?;
1017 log::debug!("request content: {:?}", local_req.body());
1018 let local_resp = local_client.execute(local_req).await?;
1019
1020 let local_status = local_resp.status();
1021 let local_content = local_resp.text().await?;
1022 log::debug!("response content: {}", local_content);
1023
1024 if !local_status.is_client_error() && !local_status.is_server_error() {
1025 match serde_json::from_str::<
1026 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
1027 >(&local_content)
1028 {
1029 Ok(e) => {
1030 return Ok(datadog::ResponseContent {
1031 status: local_status,
1032 content: local_content,
1033 entity: Some(e),
1034 })
1035 }
1036 Err(e) => return Err(datadog::Error::Serde(e)),
1037 };
1038 } else {
1039 let local_entity: Option<GetWorkflowsWebhookHandleError> =
1040 serde_json::from_str(&local_content).ok();
1041 let local_error = datadog::ResponseContent {
1042 status: local_status,
1043 content: local_content,
1044 entity: local_entity,
1045 };
1046 Err(datadog::Error::ResponseError(local_error))
1047 }
1048 }
1049
1050 pub async fn list_tenant_based_handles(
1052 &self,
1053 params: ListTenantBasedHandlesOptionalParams,
1054 ) -> Result<
1055 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandlesResponse,
1056 datadog::Error<ListTenantBasedHandlesError>,
1057 > {
1058 match self.list_tenant_based_handles_with_http_info(params).await {
1059 Ok(response_content) => {
1060 if let Some(e) = response_content.entity {
1061 Ok(e)
1062 } else {
1063 Err(datadog::Error::Serde(serde::de::Error::custom(
1064 "response content was None",
1065 )))
1066 }
1067 }
1068 Err(err) => Err(err),
1069 }
1070 }
1071
1072 pub async fn list_tenant_based_handles_with_http_info(
1074 &self,
1075 params: ListTenantBasedHandlesOptionalParams,
1076 ) -> Result<
1077 datadog::ResponseContent<crate::datadogV2::model::MicrosoftTeamsTenantBasedHandlesResponse>,
1078 datadog::Error<ListTenantBasedHandlesError>,
1079 > {
1080 let local_configuration = &self.config;
1081 let operation_id = "v2.list_tenant_based_handles";
1082
1083 let tenant_id = params.tenant_id;
1085 let name = params.name;
1086
1087 let local_client = &self.client;
1088
1089 let local_uri_str = format!(
1090 "{}/api/v2/integration/ms-teams/configuration/tenant-based-handles",
1091 local_configuration.get_operation_host(operation_id)
1092 );
1093 let mut local_req_builder =
1094 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1095
1096 if let Some(ref local_query_param) = tenant_id {
1097 local_req_builder =
1098 local_req_builder.query(&[("tenant_id", &local_query_param.to_string())]);
1099 };
1100 if let Some(ref local_query_param) = name {
1101 local_req_builder =
1102 local_req_builder.query(&[("name", &local_query_param.to_string())]);
1103 };
1104
1105 let mut headers = HeaderMap::new();
1107 headers.insert("Accept", HeaderValue::from_static("application/json"));
1108
1109 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1111 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1112 Err(e) => {
1113 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1114 headers.insert(
1115 reqwest::header::USER_AGENT,
1116 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1117 )
1118 }
1119 };
1120
1121 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1123 headers.insert(
1124 "DD-API-KEY",
1125 HeaderValue::from_str(local_key.key.as_str())
1126 .expect("failed to parse DD-API-KEY header"),
1127 );
1128 };
1129 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1130 headers.insert(
1131 "DD-APPLICATION-KEY",
1132 HeaderValue::from_str(local_key.key.as_str())
1133 .expect("failed to parse DD-APPLICATION-KEY header"),
1134 );
1135 };
1136
1137 local_req_builder = local_req_builder.headers(headers);
1138 let local_req = local_req_builder.build()?;
1139 log::debug!("request content: {:?}", local_req.body());
1140 let local_resp = local_client.execute(local_req).await?;
1141
1142 let local_status = local_resp.status();
1143 let local_content = local_resp.text().await?;
1144 log::debug!("response content: {}", local_content);
1145
1146 if !local_status.is_client_error() && !local_status.is_server_error() {
1147 match serde_json::from_str::<
1148 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandlesResponse,
1149 >(&local_content)
1150 {
1151 Ok(e) => {
1152 return Ok(datadog::ResponseContent {
1153 status: local_status,
1154 content: local_content,
1155 entity: Some(e),
1156 })
1157 }
1158 Err(e) => return Err(datadog::Error::Serde(e)),
1159 };
1160 } else {
1161 let local_entity: Option<ListTenantBasedHandlesError> =
1162 serde_json::from_str(&local_content).ok();
1163 let local_error = datadog::ResponseContent {
1164 status: local_status,
1165 content: local_content,
1166 entity: local_entity,
1167 };
1168 Err(datadog::Error::ResponseError(local_error))
1169 }
1170 }
1171
1172 pub async fn list_workflows_webhook_handles(
1174 &self,
1175 params: ListWorkflowsWebhookHandlesOptionalParams,
1176 ) -> Result<
1177 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandlesResponse,
1178 datadog::Error<ListWorkflowsWebhookHandlesError>,
1179 > {
1180 match self
1181 .list_workflows_webhook_handles_with_http_info(params)
1182 .await
1183 {
1184 Ok(response_content) => {
1185 if let Some(e) = response_content.entity {
1186 Ok(e)
1187 } else {
1188 Err(datadog::Error::Serde(serde::de::Error::custom(
1189 "response content was None",
1190 )))
1191 }
1192 }
1193 Err(err) => Err(err),
1194 }
1195 }
1196
1197 pub async fn list_workflows_webhook_handles_with_http_info(
1199 &self,
1200 params: ListWorkflowsWebhookHandlesOptionalParams,
1201 ) -> Result<
1202 datadog::ResponseContent<
1203 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandlesResponse,
1204 >,
1205 datadog::Error<ListWorkflowsWebhookHandlesError>,
1206 > {
1207 let local_configuration = &self.config;
1208 let operation_id = "v2.list_workflows_webhook_handles";
1209
1210 let name = params.name;
1212
1213 let local_client = &self.client;
1214
1215 let local_uri_str = format!(
1216 "{}/api/v2/integration/ms-teams/configuration/workflows-webhook-handles",
1217 local_configuration.get_operation_host(operation_id)
1218 );
1219 let mut local_req_builder =
1220 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1221
1222 if let Some(ref local_query_param) = name {
1223 local_req_builder =
1224 local_req_builder.query(&[("name", &local_query_param.to_string())]);
1225 };
1226
1227 let mut headers = HeaderMap::new();
1229 headers.insert("Accept", HeaderValue::from_static("application/json"));
1230
1231 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1233 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1234 Err(e) => {
1235 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1236 headers.insert(
1237 reqwest::header::USER_AGENT,
1238 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1239 )
1240 }
1241 };
1242
1243 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1245 headers.insert(
1246 "DD-API-KEY",
1247 HeaderValue::from_str(local_key.key.as_str())
1248 .expect("failed to parse DD-API-KEY header"),
1249 );
1250 };
1251 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1252 headers.insert(
1253 "DD-APPLICATION-KEY",
1254 HeaderValue::from_str(local_key.key.as_str())
1255 .expect("failed to parse DD-APPLICATION-KEY header"),
1256 );
1257 };
1258
1259 local_req_builder = local_req_builder.headers(headers);
1260 let local_req = local_req_builder.build()?;
1261 log::debug!("request content: {:?}", local_req.body());
1262 let local_resp = local_client.execute(local_req).await?;
1263
1264 let local_status = local_resp.status();
1265 let local_content = local_resp.text().await?;
1266 log::debug!("response content: {}", local_content);
1267
1268 if !local_status.is_client_error() && !local_status.is_server_error() {
1269 match serde_json::from_str::<
1270 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandlesResponse,
1271 >(&local_content)
1272 {
1273 Ok(e) => {
1274 return Ok(datadog::ResponseContent {
1275 status: local_status,
1276 content: local_content,
1277 entity: Some(e),
1278 })
1279 }
1280 Err(e) => return Err(datadog::Error::Serde(e)),
1281 };
1282 } else {
1283 let local_entity: Option<ListWorkflowsWebhookHandlesError> =
1284 serde_json::from_str(&local_content).ok();
1285 let local_error = datadog::ResponseContent {
1286 status: local_status,
1287 content: local_content,
1288 entity: local_entity,
1289 };
1290 Err(datadog::Error::ResponseError(local_error))
1291 }
1292 }
1293
1294 pub async fn update_tenant_based_handle(
1296 &self,
1297 handle_id: String,
1298 body: crate::datadogV2::model::MicrosoftTeamsUpdateTenantBasedHandleRequest,
1299 ) -> Result<
1300 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
1301 datadog::Error<UpdateTenantBasedHandleError>,
1302 > {
1303 match self
1304 .update_tenant_based_handle_with_http_info(handle_id, body)
1305 .await
1306 {
1307 Ok(response_content) => {
1308 if let Some(e) = response_content.entity {
1309 Ok(e)
1310 } else {
1311 Err(datadog::Error::Serde(serde::de::Error::custom(
1312 "response content was None",
1313 )))
1314 }
1315 }
1316 Err(err) => Err(err),
1317 }
1318 }
1319
1320 pub async fn update_tenant_based_handle_with_http_info(
1322 &self,
1323 handle_id: String,
1324 body: crate::datadogV2::model::MicrosoftTeamsUpdateTenantBasedHandleRequest,
1325 ) -> Result<
1326 datadog::ResponseContent<crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse>,
1327 datadog::Error<UpdateTenantBasedHandleError>,
1328 > {
1329 let local_configuration = &self.config;
1330 let operation_id = "v2.update_tenant_based_handle";
1331
1332 let local_client = &self.client;
1333
1334 let local_uri_str = format!(
1335 "{}/api/v2/integration/ms-teams/configuration/tenant-based-handles/{handle_id}",
1336 local_configuration.get_operation_host(operation_id),
1337 handle_id = datadog::urlencode(handle_id)
1338 );
1339 let mut local_req_builder =
1340 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1341
1342 let mut headers = HeaderMap::new();
1344 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1345 headers.insert("Accept", HeaderValue::from_static("application/json"));
1346
1347 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1349 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1350 Err(e) => {
1351 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1352 headers.insert(
1353 reqwest::header::USER_AGENT,
1354 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1355 )
1356 }
1357 };
1358
1359 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1361 headers.insert(
1362 "DD-API-KEY",
1363 HeaderValue::from_str(local_key.key.as_str())
1364 .expect("failed to parse DD-API-KEY header"),
1365 );
1366 };
1367 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1368 headers.insert(
1369 "DD-APPLICATION-KEY",
1370 HeaderValue::from_str(local_key.key.as_str())
1371 .expect("failed to parse DD-APPLICATION-KEY header"),
1372 );
1373 };
1374
1375 let output = Vec::new();
1377 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1378 if body.serialize(&mut ser).is_ok() {
1379 if let Some(content_encoding) = headers.get("Content-Encoding") {
1380 match content_encoding.to_str().unwrap_or_default() {
1381 "gzip" => {
1382 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1383 let _ = enc.write_all(ser.into_inner().as_slice());
1384 match enc.finish() {
1385 Ok(buf) => {
1386 local_req_builder = local_req_builder.body(buf);
1387 }
1388 Err(e) => return Err(datadog::Error::Io(e)),
1389 }
1390 }
1391 "deflate" => {
1392 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1393 let _ = enc.write_all(ser.into_inner().as_slice());
1394 match enc.finish() {
1395 Ok(buf) => {
1396 local_req_builder = local_req_builder.body(buf);
1397 }
1398 Err(e) => return Err(datadog::Error::Io(e)),
1399 }
1400 }
1401 "zstd1" => {
1402 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1403 let _ = enc.write_all(ser.into_inner().as_slice());
1404 match enc.finish() {
1405 Ok(buf) => {
1406 local_req_builder = local_req_builder.body(buf);
1407 }
1408 Err(e) => return Err(datadog::Error::Io(e)),
1409 }
1410 }
1411 _ => {
1412 local_req_builder = local_req_builder.body(ser.into_inner());
1413 }
1414 }
1415 } else {
1416 local_req_builder = local_req_builder.body(ser.into_inner());
1417 }
1418 }
1419
1420 local_req_builder = local_req_builder.headers(headers);
1421 let local_req = local_req_builder.build()?;
1422 log::debug!("request content: {:?}", local_req.body());
1423 let local_resp = local_client.execute(local_req).await?;
1424
1425 let local_status = local_resp.status();
1426 let local_content = local_resp.text().await?;
1427 log::debug!("response content: {}", local_content);
1428
1429 if !local_status.is_client_error() && !local_status.is_server_error() {
1430 match serde_json::from_str::<
1431 crate::datadogV2::model::MicrosoftTeamsTenantBasedHandleResponse,
1432 >(&local_content)
1433 {
1434 Ok(e) => {
1435 return Ok(datadog::ResponseContent {
1436 status: local_status,
1437 content: local_content,
1438 entity: Some(e),
1439 })
1440 }
1441 Err(e) => return Err(datadog::Error::Serde(e)),
1442 };
1443 } else {
1444 let local_entity: Option<UpdateTenantBasedHandleError> =
1445 serde_json::from_str(&local_content).ok();
1446 let local_error = datadog::ResponseContent {
1447 status: local_status,
1448 content: local_content,
1449 entity: local_entity,
1450 };
1451 Err(datadog::Error::ResponseError(local_error))
1452 }
1453 }
1454
1455 pub async fn update_workflows_webhook_handle(
1457 &self,
1458 handle_id: String,
1459 body: crate::datadogV2::model::MicrosoftTeamsUpdateWorkflowsWebhookHandleRequest,
1460 ) -> Result<
1461 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
1462 datadog::Error<UpdateWorkflowsWebhookHandleError>,
1463 > {
1464 match self
1465 .update_workflows_webhook_handle_with_http_info(handle_id, body)
1466 .await
1467 {
1468 Ok(response_content) => {
1469 if let Some(e) = response_content.entity {
1470 Ok(e)
1471 } else {
1472 Err(datadog::Error::Serde(serde::de::Error::custom(
1473 "response content was None",
1474 )))
1475 }
1476 }
1477 Err(err) => Err(err),
1478 }
1479 }
1480
1481 pub async fn update_workflows_webhook_handle_with_http_info(
1483 &self,
1484 handle_id: String,
1485 body: crate::datadogV2::model::MicrosoftTeamsUpdateWorkflowsWebhookHandleRequest,
1486 ) -> Result<
1487 datadog::ResponseContent<
1488 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
1489 >,
1490 datadog::Error<UpdateWorkflowsWebhookHandleError>,
1491 > {
1492 let local_configuration = &self.config;
1493 let operation_id = "v2.update_workflows_webhook_handle";
1494
1495 let local_client = &self.client;
1496
1497 let local_uri_str = format!(
1498 "{}/api/v2/integration/ms-teams/configuration/workflows-webhook-handles/{handle_id}",
1499 local_configuration.get_operation_host(operation_id),
1500 handle_id = datadog::urlencode(handle_id)
1501 );
1502 let mut local_req_builder =
1503 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1504
1505 let mut headers = HeaderMap::new();
1507 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1508 headers.insert("Accept", HeaderValue::from_static("application/json"));
1509
1510 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1512 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1513 Err(e) => {
1514 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1515 headers.insert(
1516 reqwest::header::USER_AGENT,
1517 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1518 )
1519 }
1520 };
1521
1522 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1524 headers.insert(
1525 "DD-API-KEY",
1526 HeaderValue::from_str(local_key.key.as_str())
1527 .expect("failed to parse DD-API-KEY header"),
1528 );
1529 };
1530 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1531 headers.insert(
1532 "DD-APPLICATION-KEY",
1533 HeaderValue::from_str(local_key.key.as_str())
1534 .expect("failed to parse DD-APPLICATION-KEY header"),
1535 );
1536 };
1537
1538 let output = Vec::new();
1540 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1541 if body.serialize(&mut ser).is_ok() {
1542 if let Some(content_encoding) = headers.get("Content-Encoding") {
1543 match content_encoding.to_str().unwrap_or_default() {
1544 "gzip" => {
1545 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1546 let _ = enc.write_all(ser.into_inner().as_slice());
1547 match enc.finish() {
1548 Ok(buf) => {
1549 local_req_builder = local_req_builder.body(buf);
1550 }
1551 Err(e) => return Err(datadog::Error::Io(e)),
1552 }
1553 }
1554 "deflate" => {
1555 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1556 let _ = enc.write_all(ser.into_inner().as_slice());
1557 match enc.finish() {
1558 Ok(buf) => {
1559 local_req_builder = local_req_builder.body(buf);
1560 }
1561 Err(e) => return Err(datadog::Error::Io(e)),
1562 }
1563 }
1564 "zstd1" => {
1565 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1566 let _ = enc.write_all(ser.into_inner().as_slice());
1567 match enc.finish() {
1568 Ok(buf) => {
1569 local_req_builder = local_req_builder.body(buf);
1570 }
1571 Err(e) => return Err(datadog::Error::Io(e)),
1572 }
1573 }
1574 _ => {
1575 local_req_builder = local_req_builder.body(ser.into_inner());
1576 }
1577 }
1578 } else {
1579 local_req_builder = local_req_builder.body(ser.into_inner());
1580 }
1581 }
1582
1583 local_req_builder = local_req_builder.headers(headers);
1584 let local_req = local_req_builder.build()?;
1585 log::debug!("request content: {:?}", local_req.body());
1586 let local_resp = local_client.execute(local_req).await?;
1587
1588 let local_status = local_resp.status();
1589 let local_content = local_resp.text().await?;
1590 log::debug!("response content: {}", local_content);
1591
1592 if !local_status.is_client_error() && !local_status.is_server_error() {
1593 match serde_json::from_str::<
1594 crate::datadogV2::model::MicrosoftTeamsWorkflowsWebhookHandleResponse,
1595 >(&local_content)
1596 {
1597 Ok(e) => {
1598 return Ok(datadog::ResponseContent {
1599 status: local_status,
1600 content: local_content,
1601 entity: Some(e),
1602 })
1603 }
1604 Err(e) => return Err(datadog::Error::Serde(e)),
1605 };
1606 } else {
1607 let local_entity: Option<UpdateWorkflowsWebhookHandleError> =
1608 serde_json::from_str(&local_content).ok();
1609 let local_error = datadog::ResponseContent {
1610 status: local_status,
1611 content: local_content,
1612 entity: local_entity,
1613 };
1614 Err(datadog::Error::ResponseError(local_error))
1615 }
1616 }
1617}