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#[derive(Debug, Clone, Serialize, Deserialize)]
15#[serde(untagged)]
16pub enum CreateApplicationSecurityWafCustomRuleError {
17 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
18 UnknownValue(serde_json::Value),
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum CreateApplicationSecurityWafExclusionFilterError {
25 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
26 UnknownValue(serde_json::Value),
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum DeleteApplicationSecurityWafCustomRuleError {
33 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum DeleteApplicationSecurityWafExclusionFilterError {
41 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetApplicationSecurityWafCustomRuleError {
49 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetApplicationSecurityWafExclusionFilterError {
57 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum ListApplicationSecurityWAFCustomRulesError {
65 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
66 UnknownValue(serde_json::Value),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum ListApplicationSecurityWafExclusionFiltersError {
73 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum UpdateApplicationSecurityWafCustomRuleError {
81 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum UpdateApplicationSecurityWafExclusionFilterError {
89 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone)]
100pub struct ApplicationSecurityAPI {
101 config: datadog::Configuration,
102 client: reqwest_middleware::ClientWithMiddleware,
103}
104
105impl Default for ApplicationSecurityAPI {
106 fn default() -> Self {
107 Self::with_config(datadog::Configuration::default())
108 }
109}
110
111impl ApplicationSecurityAPI {
112 pub fn new() -> Self {
113 Self::default()
114 }
115 pub fn with_config(config: datadog::Configuration) -> Self {
116 let mut reqwest_client_builder = reqwest::Client::builder();
117
118 if let Some(proxy_url) = &config.proxy_url {
119 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
120 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
121 }
122
123 let mut middleware_client_builder =
124 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
125
126 if config.enable_retry {
127 struct RetryableStatus;
128 impl reqwest_retry::RetryableStrategy for RetryableStatus {
129 fn handle(
130 &self,
131 res: &Result<reqwest::Response, reqwest_middleware::Error>,
132 ) -> Option<reqwest_retry::Retryable> {
133 match res {
134 Ok(success) => reqwest_retry::default_on_request_success(success),
135 Err(_) => None,
136 }
137 }
138 }
139 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
140 .build_with_max_retries(config.max_retries);
141
142 let retry_middleware =
143 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
144 backoff_policy,
145 RetryableStatus,
146 );
147
148 middleware_client_builder = middleware_client_builder.with(retry_middleware);
149 }
150
151 let client = middleware_client_builder.build();
152
153 Self { config, client }
154 }
155
156 pub fn with_client_and_config(
157 config: datadog::Configuration,
158 client: reqwest_middleware::ClientWithMiddleware,
159 ) -> Self {
160 Self { config, client }
161 }
162
163 pub async fn create_application_security_waf_custom_rule(
165 &self,
166 body: crate::datadogV2::model::ApplicationSecurityWafCustomRuleCreateRequest,
167 ) -> Result<
168 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
169 datadog::Error<CreateApplicationSecurityWafCustomRuleError>,
170 > {
171 match self
172 .create_application_security_waf_custom_rule_with_http_info(body)
173 .await
174 {
175 Ok(response_content) => {
176 if let Some(e) = response_content.entity {
177 Ok(e)
178 } else {
179 Err(datadog::Error::Serde(serde::de::Error::custom(
180 "response content was None",
181 )))
182 }
183 }
184 Err(err) => Err(err),
185 }
186 }
187
188 pub async fn create_application_security_waf_custom_rule_with_http_info(
190 &self,
191 body: crate::datadogV2::model::ApplicationSecurityWafCustomRuleCreateRequest,
192 ) -> Result<
193 datadog::ResponseContent<crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse>,
194 datadog::Error<CreateApplicationSecurityWafCustomRuleError>,
195 > {
196 let local_configuration = &self.config;
197 let operation_id = "v2.create_application_security_waf_custom_rule";
198
199 let local_client = &self.client;
200
201 let local_uri_str = format!(
202 "{}/api/v2/remote_config/products/asm/waf/custom_rules",
203 local_configuration.get_operation_host(operation_id)
204 );
205 let mut local_req_builder =
206 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
207
208 let mut headers = HeaderMap::new();
210 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
211 headers.insert("Accept", HeaderValue::from_static("application/json"));
212
213 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
215 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
216 Err(e) => {
217 log::warn!("Failed to parse user agent header: {e}, falling back to default");
218 headers.insert(
219 reqwest::header::USER_AGENT,
220 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
221 )
222 }
223 };
224
225 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
227 headers.insert(
228 "DD-API-KEY",
229 HeaderValue::from_str(local_key.key.as_str())
230 .expect("failed to parse DD-API-KEY header"),
231 );
232 };
233 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
234 headers.insert(
235 "DD-APPLICATION-KEY",
236 HeaderValue::from_str(local_key.key.as_str())
237 .expect("failed to parse DD-APPLICATION-KEY header"),
238 );
239 };
240
241 let output = Vec::new();
243 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
244 if body.serialize(&mut ser).is_ok() {
245 if let Some(content_encoding) = headers.get("Content-Encoding") {
246 match content_encoding.to_str().unwrap_or_default() {
247 "gzip" => {
248 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
249 let _ = enc.write_all(ser.into_inner().as_slice());
250 match enc.finish() {
251 Ok(buf) => {
252 local_req_builder = local_req_builder.body(buf);
253 }
254 Err(e) => return Err(datadog::Error::Io(e)),
255 }
256 }
257 "deflate" => {
258 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
259 let _ = enc.write_all(ser.into_inner().as_slice());
260 match enc.finish() {
261 Ok(buf) => {
262 local_req_builder = local_req_builder.body(buf);
263 }
264 Err(e) => return Err(datadog::Error::Io(e)),
265 }
266 }
267 "zstd1" => {
268 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
269 let _ = enc.write_all(ser.into_inner().as_slice());
270 match enc.finish() {
271 Ok(buf) => {
272 local_req_builder = local_req_builder.body(buf);
273 }
274 Err(e) => return Err(datadog::Error::Io(e)),
275 }
276 }
277 _ => {
278 local_req_builder = local_req_builder.body(ser.into_inner());
279 }
280 }
281 } else {
282 local_req_builder = local_req_builder.body(ser.into_inner());
283 }
284 }
285
286 local_req_builder = local_req_builder.headers(headers);
287 let local_req = local_req_builder.build()?;
288 log::debug!("request content: {:?}", local_req.body());
289 let local_resp = local_client.execute(local_req).await?;
290
291 let local_status = local_resp.status();
292 let local_content = local_resp.text().await?;
293 log::debug!("response content: {}", local_content);
294
295 if !local_status.is_client_error() && !local_status.is_server_error() {
296 match serde_json::from_str::<
297 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
298 >(&local_content)
299 {
300 Ok(e) => {
301 return Ok(datadog::ResponseContent {
302 status: local_status,
303 content: local_content,
304 entity: Some(e),
305 })
306 }
307 Err(e) => return Err(datadog::Error::Serde(e)),
308 };
309 } else {
310 let local_entity: Option<CreateApplicationSecurityWafCustomRuleError> =
311 serde_json::from_str(&local_content).ok();
312 let local_error = datadog::ResponseContent {
313 status: local_status,
314 content: local_content,
315 entity: local_entity,
316 };
317 Err(datadog::Error::ResponseError(local_error))
318 }
319 }
320
321 pub async fn create_application_security_waf_exclusion_filter(
326 &self,
327 body: crate::datadogV2::model::ApplicationSecurityWafExclusionFilterCreateRequest,
328 ) -> Result<
329 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
330 datadog::Error<CreateApplicationSecurityWafExclusionFilterError>,
331 > {
332 match self
333 .create_application_security_waf_exclusion_filter_with_http_info(body)
334 .await
335 {
336 Ok(response_content) => {
337 if let Some(e) = response_content.entity {
338 Ok(e)
339 } else {
340 Err(datadog::Error::Serde(serde::de::Error::custom(
341 "response content was None",
342 )))
343 }
344 }
345 Err(err) => Err(err),
346 }
347 }
348
349 pub async fn create_application_security_waf_exclusion_filter_with_http_info(
354 &self,
355 body: crate::datadogV2::model::ApplicationSecurityWafExclusionFilterCreateRequest,
356 ) -> Result<
357 datadog::ResponseContent<
358 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
359 >,
360 datadog::Error<CreateApplicationSecurityWafExclusionFilterError>,
361 > {
362 let local_configuration = &self.config;
363 let operation_id = "v2.create_application_security_waf_exclusion_filter";
364
365 let local_client = &self.client;
366
367 let local_uri_str = format!(
368 "{}/api/v2/remote_config/products/asm/waf/exclusion_filters",
369 local_configuration.get_operation_host(operation_id)
370 );
371 let mut local_req_builder =
372 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
373
374 let mut headers = HeaderMap::new();
376 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
377 headers.insert("Accept", HeaderValue::from_static("application/json"));
378
379 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
381 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
382 Err(e) => {
383 log::warn!("Failed to parse user agent header: {e}, falling back to default");
384 headers.insert(
385 reqwest::header::USER_AGENT,
386 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
387 )
388 }
389 };
390
391 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
393 headers.insert(
394 "DD-API-KEY",
395 HeaderValue::from_str(local_key.key.as_str())
396 .expect("failed to parse DD-API-KEY header"),
397 );
398 };
399 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
400 headers.insert(
401 "DD-APPLICATION-KEY",
402 HeaderValue::from_str(local_key.key.as_str())
403 .expect("failed to parse DD-APPLICATION-KEY header"),
404 );
405 };
406
407 let output = Vec::new();
409 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
410 if body.serialize(&mut ser).is_ok() {
411 if let Some(content_encoding) = headers.get("Content-Encoding") {
412 match content_encoding.to_str().unwrap_or_default() {
413 "gzip" => {
414 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
415 let _ = enc.write_all(ser.into_inner().as_slice());
416 match enc.finish() {
417 Ok(buf) => {
418 local_req_builder = local_req_builder.body(buf);
419 }
420 Err(e) => return Err(datadog::Error::Io(e)),
421 }
422 }
423 "deflate" => {
424 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
425 let _ = enc.write_all(ser.into_inner().as_slice());
426 match enc.finish() {
427 Ok(buf) => {
428 local_req_builder = local_req_builder.body(buf);
429 }
430 Err(e) => return Err(datadog::Error::Io(e)),
431 }
432 }
433 "zstd1" => {
434 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
435 let _ = enc.write_all(ser.into_inner().as_slice());
436 match enc.finish() {
437 Ok(buf) => {
438 local_req_builder = local_req_builder.body(buf);
439 }
440 Err(e) => return Err(datadog::Error::Io(e)),
441 }
442 }
443 _ => {
444 local_req_builder = local_req_builder.body(ser.into_inner());
445 }
446 }
447 } else {
448 local_req_builder = local_req_builder.body(ser.into_inner());
449 }
450 }
451
452 local_req_builder = local_req_builder.headers(headers);
453 let local_req = local_req_builder.build()?;
454 log::debug!("request content: {:?}", local_req.body());
455 let local_resp = local_client.execute(local_req).await?;
456
457 let local_status = local_resp.status();
458 let local_content = local_resp.text().await?;
459 log::debug!("response content: {}", local_content);
460
461 if !local_status.is_client_error() && !local_status.is_server_error() {
462 match serde_json::from_str::<
463 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
464 >(&local_content)
465 {
466 Ok(e) => {
467 return Ok(datadog::ResponseContent {
468 status: local_status,
469 content: local_content,
470 entity: Some(e),
471 })
472 }
473 Err(e) => return Err(datadog::Error::Serde(e)),
474 };
475 } else {
476 let local_entity: Option<CreateApplicationSecurityWafExclusionFilterError> =
477 serde_json::from_str(&local_content).ok();
478 let local_error = datadog::ResponseContent {
479 status: local_status,
480 content: local_content,
481 entity: local_entity,
482 };
483 Err(datadog::Error::ResponseError(local_error))
484 }
485 }
486
487 pub async fn delete_application_security_waf_custom_rule(
489 &self,
490 custom_rule_id: String,
491 ) -> Result<(), datadog::Error<DeleteApplicationSecurityWafCustomRuleError>> {
492 match self
493 .delete_application_security_waf_custom_rule_with_http_info(custom_rule_id)
494 .await
495 {
496 Ok(_) => Ok(()),
497 Err(err) => Err(err),
498 }
499 }
500
501 pub async fn delete_application_security_waf_custom_rule_with_http_info(
503 &self,
504 custom_rule_id: String,
505 ) -> Result<
506 datadog::ResponseContent<()>,
507 datadog::Error<DeleteApplicationSecurityWafCustomRuleError>,
508 > {
509 let local_configuration = &self.config;
510 let operation_id = "v2.delete_application_security_waf_custom_rule";
511
512 let local_client = &self.client;
513
514 let local_uri_str = format!(
515 "{}/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}",
516 local_configuration.get_operation_host(operation_id),
517 custom_rule_id = datadog::urlencode(custom_rule_id)
518 );
519 let mut local_req_builder =
520 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
521
522 let mut headers = HeaderMap::new();
524 headers.insert("Accept", HeaderValue::from_static("*/*"));
525
526 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
528 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
529 Err(e) => {
530 log::warn!("Failed to parse user agent header: {e}, falling back to default");
531 headers.insert(
532 reqwest::header::USER_AGENT,
533 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
534 )
535 }
536 };
537
538 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
540 headers.insert(
541 "DD-API-KEY",
542 HeaderValue::from_str(local_key.key.as_str())
543 .expect("failed to parse DD-API-KEY header"),
544 );
545 };
546 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
547 headers.insert(
548 "DD-APPLICATION-KEY",
549 HeaderValue::from_str(local_key.key.as_str())
550 .expect("failed to parse DD-APPLICATION-KEY header"),
551 );
552 };
553
554 local_req_builder = local_req_builder.headers(headers);
555 let local_req = local_req_builder.build()?;
556 log::debug!("request content: {:?}", local_req.body());
557 let local_resp = local_client.execute(local_req).await?;
558
559 let local_status = local_resp.status();
560 let local_content = local_resp.text().await?;
561 log::debug!("response content: {}", local_content);
562
563 if !local_status.is_client_error() && !local_status.is_server_error() {
564 Ok(datadog::ResponseContent {
565 status: local_status,
566 content: local_content,
567 entity: None,
568 })
569 } else {
570 let local_entity: Option<DeleteApplicationSecurityWafCustomRuleError> =
571 serde_json::from_str(&local_content).ok();
572 let local_error = datadog::ResponseContent {
573 status: local_status,
574 content: local_content,
575 entity: local_entity,
576 };
577 Err(datadog::Error::ResponseError(local_error))
578 }
579 }
580
581 pub async fn delete_application_security_waf_exclusion_filter(
583 &self,
584 exclusion_filter_id: String,
585 ) -> Result<(), datadog::Error<DeleteApplicationSecurityWafExclusionFilterError>> {
586 match self
587 .delete_application_security_waf_exclusion_filter_with_http_info(exclusion_filter_id)
588 .await
589 {
590 Ok(_) => Ok(()),
591 Err(err) => Err(err),
592 }
593 }
594
595 pub async fn delete_application_security_waf_exclusion_filter_with_http_info(
597 &self,
598 exclusion_filter_id: String,
599 ) -> Result<
600 datadog::ResponseContent<()>,
601 datadog::Error<DeleteApplicationSecurityWafExclusionFilterError>,
602 > {
603 let local_configuration = &self.config;
604 let operation_id = "v2.delete_application_security_waf_exclusion_filter";
605
606 let local_client = &self.client;
607
608 let local_uri_str = format!(
609 "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}",
610 local_configuration.get_operation_host(operation_id),
611 exclusion_filter_id = datadog::urlencode(exclusion_filter_id)
612 );
613 let mut local_req_builder =
614 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
615
616 let mut headers = HeaderMap::new();
618 headers.insert("Accept", HeaderValue::from_static("*/*"));
619
620 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
622 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
623 Err(e) => {
624 log::warn!("Failed to parse user agent header: {e}, falling back to default");
625 headers.insert(
626 reqwest::header::USER_AGENT,
627 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
628 )
629 }
630 };
631
632 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
634 headers.insert(
635 "DD-API-KEY",
636 HeaderValue::from_str(local_key.key.as_str())
637 .expect("failed to parse DD-API-KEY header"),
638 );
639 };
640 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
641 headers.insert(
642 "DD-APPLICATION-KEY",
643 HeaderValue::from_str(local_key.key.as_str())
644 .expect("failed to parse DD-APPLICATION-KEY header"),
645 );
646 };
647
648 local_req_builder = local_req_builder.headers(headers);
649 let local_req = local_req_builder.build()?;
650 log::debug!("request content: {:?}", local_req.body());
651 let local_resp = local_client.execute(local_req).await?;
652
653 let local_status = local_resp.status();
654 let local_content = local_resp.text().await?;
655 log::debug!("response content: {}", local_content);
656
657 if !local_status.is_client_error() && !local_status.is_server_error() {
658 Ok(datadog::ResponseContent {
659 status: local_status,
660 content: local_content,
661 entity: None,
662 })
663 } else {
664 let local_entity: Option<DeleteApplicationSecurityWafExclusionFilterError> =
665 serde_json::from_str(&local_content).ok();
666 let local_error = datadog::ResponseContent {
667 status: local_status,
668 content: local_content,
669 entity: local_entity,
670 };
671 Err(datadog::Error::ResponseError(local_error))
672 }
673 }
674
675 pub async fn get_application_security_waf_custom_rule(
677 &self,
678 custom_rule_id: String,
679 ) -> Result<
680 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
681 datadog::Error<GetApplicationSecurityWafCustomRuleError>,
682 > {
683 match self
684 .get_application_security_waf_custom_rule_with_http_info(custom_rule_id)
685 .await
686 {
687 Ok(response_content) => {
688 if let Some(e) = response_content.entity {
689 Ok(e)
690 } else {
691 Err(datadog::Error::Serde(serde::de::Error::custom(
692 "response content was None",
693 )))
694 }
695 }
696 Err(err) => Err(err),
697 }
698 }
699
700 pub async fn get_application_security_waf_custom_rule_with_http_info(
702 &self,
703 custom_rule_id: String,
704 ) -> Result<
705 datadog::ResponseContent<crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse>,
706 datadog::Error<GetApplicationSecurityWafCustomRuleError>,
707 > {
708 let local_configuration = &self.config;
709 let operation_id = "v2.get_application_security_waf_custom_rule";
710
711 let local_client = &self.client;
712
713 let local_uri_str = format!(
714 "{}/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}",
715 local_configuration.get_operation_host(operation_id),
716 custom_rule_id = datadog::urlencode(custom_rule_id)
717 );
718 let mut local_req_builder =
719 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
720
721 let mut headers = HeaderMap::new();
723 headers.insert("Accept", HeaderValue::from_static("application/json"));
724
725 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
727 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
728 Err(e) => {
729 log::warn!("Failed to parse user agent header: {e}, falling back to default");
730 headers.insert(
731 reqwest::header::USER_AGENT,
732 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
733 )
734 }
735 };
736
737 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
739 headers.insert(
740 "DD-API-KEY",
741 HeaderValue::from_str(local_key.key.as_str())
742 .expect("failed to parse DD-API-KEY header"),
743 );
744 };
745 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
746 headers.insert(
747 "DD-APPLICATION-KEY",
748 HeaderValue::from_str(local_key.key.as_str())
749 .expect("failed to parse DD-APPLICATION-KEY header"),
750 );
751 };
752
753 local_req_builder = local_req_builder.headers(headers);
754 let local_req = local_req_builder.build()?;
755 log::debug!("request content: {:?}", local_req.body());
756 let local_resp = local_client.execute(local_req).await?;
757
758 let local_status = local_resp.status();
759 let local_content = local_resp.text().await?;
760 log::debug!("response content: {}", local_content);
761
762 if !local_status.is_client_error() && !local_status.is_server_error() {
763 match serde_json::from_str::<
764 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
765 >(&local_content)
766 {
767 Ok(e) => {
768 return Ok(datadog::ResponseContent {
769 status: local_status,
770 content: local_content,
771 entity: Some(e),
772 })
773 }
774 Err(e) => return Err(datadog::Error::Serde(e)),
775 };
776 } else {
777 let local_entity: Option<GetApplicationSecurityWafCustomRuleError> =
778 serde_json::from_str(&local_content).ok();
779 let local_error = datadog::ResponseContent {
780 status: local_status,
781 content: local_content,
782 entity: local_entity,
783 };
784 Err(datadog::Error::ResponseError(local_error))
785 }
786 }
787
788 pub async fn get_application_security_waf_exclusion_filter(
790 &self,
791 exclusion_filter_id: String,
792 ) -> Result<
793 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
794 datadog::Error<GetApplicationSecurityWafExclusionFilterError>,
795 > {
796 match self
797 .get_application_security_waf_exclusion_filter_with_http_info(exclusion_filter_id)
798 .await
799 {
800 Ok(response_content) => {
801 if let Some(e) = response_content.entity {
802 Ok(e)
803 } else {
804 Err(datadog::Error::Serde(serde::de::Error::custom(
805 "response content was None",
806 )))
807 }
808 }
809 Err(err) => Err(err),
810 }
811 }
812
813 pub async fn get_application_security_waf_exclusion_filter_with_http_info(
815 &self,
816 exclusion_filter_id: String,
817 ) -> Result<
818 datadog::ResponseContent<
819 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
820 >,
821 datadog::Error<GetApplicationSecurityWafExclusionFilterError>,
822 > {
823 let local_configuration = &self.config;
824 let operation_id = "v2.get_application_security_waf_exclusion_filter";
825
826 let local_client = &self.client;
827
828 let local_uri_str = format!(
829 "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}",
830 local_configuration.get_operation_host(operation_id),
831 exclusion_filter_id = datadog::urlencode(exclusion_filter_id)
832 );
833 let mut local_req_builder =
834 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
835
836 let mut headers = HeaderMap::new();
838 headers.insert("Accept", HeaderValue::from_static("application/json"));
839
840 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
842 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
843 Err(e) => {
844 log::warn!("Failed to parse user agent header: {e}, falling back to default");
845 headers.insert(
846 reqwest::header::USER_AGENT,
847 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
848 )
849 }
850 };
851
852 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
854 headers.insert(
855 "DD-API-KEY",
856 HeaderValue::from_str(local_key.key.as_str())
857 .expect("failed to parse DD-API-KEY header"),
858 );
859 };
860 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
861 headers.insert(
862 "DD-APPLICATION-KEY",
863 HeaderValue::from_str(local_key.key.as_str())
864 .expect("failed to parse DD-APPLICATION-KEY header"),
865 );
866 };
867
868 local_req_builder = local_req_builder.headers(headers);
869 let local_req = local_req_builder.build()?;
870 log::debug!("request content: {:?}", local_req.body());
871 let local_resp = local_client.execute(local_req).await?;
872
873 let local_status = local_resp.status();
874 let local_content = local_resp.text().await?;
875 log::debug!("response content: {}", local_content);
876
877 if !local_status.is_client_error() && !local_status.is_server_error() {
878 match serde_json::from_str::<
879 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
880 >(&local_content)
881 {
882 Ok(e) => {
883 return Ok(datadog::ResponseContent {
884 status: local_status,
885 content: local_content,
886 entity: Some(e),
887 })
888 }
889 Err(e) => return Err(datadog::Error::Serde(e)),
890 };
891 } else {
892 let local_entity: Option<GetApplicationSecurityWafExclusionFilterError> =
893 serde_json::from_str(&local_content).ok();
894 let local_error = datadog::ResponseContent {
895 status: local_status,
896 content: local_content,
897 entity: local_entity,
898 };
899 Err(datadog::Error::ResponseError(local_error))
900 }
901 }
902
903 pub async fn list_application_security_waf_custom_rules(
905 &self,
906 ) -> Result<
907 crate::datadogV2::model::ApplicationSecurityWafCustomRuleListResponse,
908 datadog::Error<ListApplicationSecurityWAFCustomRulesError>,
909 > {
910 match self
911 .list_application_security_waf_custom_rules_with_http_info()
912 .await
913 {
914 Ok(response_content) => {
915 if let Some(e) = response_content.entity {
916 Ok(e)
917 } else {
918 Err(datadog::Error::Serde(serde::de::Error::custom(
919 "response content was None",
920 )))
921 }
922 }
923 Err(err) => Err(err),
924 }
925 }
926
927 pub async fn list_application_security_waf_custom_rules_with_http_info(
929 &self,
930 ) -> Result<
931 datadog::ResponseContent<
932 crate::datadogV2::model::ApplicationSecurityWafCustomRuleListResponse,
933 >,
934 datadog::Error<ListApplicationSecurityWAFCustomRulesError>,
935 > {
936 let local_configuration = &self.config;
937 let operation_id = "v2.list_application_security_waf_custom_rules";
938
939 let local_client = &self.client;
940
941 let local_uri_str = format!(
942 "{}/api/v2/remote_config/products/asm/waf/custom_rules",
943 local_configuration.get_operation_host(operation_id)
944 );
945 let mut local_req_builder =
946 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
947
948 let mut headers = HeaderMap::new();
950 headers.insert("Accept", HeaderValue::from_static("application/json"));
951
952 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
954 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
955 Err(e) => {
956 log::warn!("Failed to parse user agent header: {e}, falling back to default");
957 headers.insert(
958 reqwest::header::USER_AGENT,
959 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
960 )
961 }
962 };
963
964 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
966 headers.insert(
967 "DD-API-KEY",
968 HeaderValue::from_str(local_key.key.as_str())
969 .expect("failed to parse DD-API-KEY header"),
970 );
971 };
972 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
973 headers.insert(
974 "DD-APPLICATION-KEY",
975 HeaderValue::from_str(local_key.key.as_str())
976 .expect("failed to parse DD-APPLICATION-KEY header"),
977 );
978 };
979
980 local_req_builder = local_req_builder.headers(headers);
981 let local_req = local_req_builder.build()?;
982 log::debug!("request content: {:?}", local_req.body());
983 let local_resp = local_client.execute(local_req).await?;
984
985 let local_status = local_resp.status();
986 let local_content = local_resp.text().await?;
987 log::debug!("response content: {}", local_content);
988
989 if !local_status.is_client_error() && !local_status.is_server_error() {
990 match serde_json::from_str::<
991 crate::datadogV2::model::ApplicationSecurityWafCustomRuleListResponse,
992 >(&local_content)
993 {
994 Ok(e) => {
995 return Ok(datadog::ResponseContent {
996 status: local_status,
997 content: local_content,
998 entity: Some(e),
999 })
1000 }
1001 Err(e) => return Err(datadog::Error::Serde(e)),
1002 };
1003 } else {
1004 let local_entity: Option<ListApplicationSecurityWAFCustomRulesError> =
1005 serde_json::from_str(&local_content).ok();
1006 let local_error = datadog::ResponseContent {
1007 status: local_status,
1008 content: local_content,
1009 entity: local_entity,
1010 };
1011 Err(datadog::Error::ResponseError(local_error))
1012 }
1013 }
1014
1015 pub async fn list_application_security_waf_exclusion_filters(
1017 &self,
1018 ) -> Result<
1019 crate::datadogV2::model::ApplicationSecurityWafExclusionFiltersResponse,
1020 datadog::Error<ListApplicationSecurityWafExclusionFiltersError>,
1021 > {
1022 match self
1023 .list_application_security_waf_exclusion_filters_with_http_info()
1024 .await
1025 {
1026 Ok(response_content) => {
1027 if let Some(e) = response_content.entity {
1028 Ok(e)
1029 } else {
1030 Err(datadog::Error::Serde(serde::de::Error::custom(
1031 "response content was None",
1032 )))
1033 }
1034 }
1035 Err(err) => Err(err),
1036 }
1037 }
1038
1039 pub async fn list_application_security_waf_exclusion_filters_with_http_info(
1041 &self,
1042 ) -> Result<
1043 datadog::ResponseContent<
1044 crate::datadogV2::model::ApplicationSecurityWafExclusionFiltersResponse,
1045 >,
1046 datadog::Error<ListApplicationSecurityWafExclusionFiltersError>,
1047 > {
1048 let local_configuration = &self.config;
1049 let operation_id = "v2.list_application_security_waf_exclusion_filters";
1050
1051 let local_client = &self.client;
1052
1053 let local_uri_str = format!(
1054 "{}/api/v2/remote_config/products/asm/waf/exclusion_filters",
1055 local_configuration.get_operation_host(operation_id)
1056 );
1057 let mut local_req_builder =
1058 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1059
1060 let mut headers = HeaderMap::new();
1062 headers.insert("Accept", HeaderValue::from_static("application/json"));
1063
1064 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1066 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1067 Err(e) => {
1068 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1069 headers.insert(
1070 reqwest::header::USER_AGENT,
1071 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1072 )
1073 }
1074 };
1075
1076 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1078 headers.insert(
1079 "DD-API-KEY",
1080 HeaderValue::from_str(local_key.key.as_str())
1081 .expect("failed to parse DD-API-KEY header"),
1082 );
1083 };
1084 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1085 headers.insert(
1086 "DD-APPLICATION-KEY",
1087 HeaderValue::from_str(local_key.key.as_str())
1088 .expect("failed to parse DD-APPLICATION-KEY header"),
1089 );
1090 };
1091
1092 local_req_builder = local_req_builder.headers(headers);
1093 let local_req = local_req_builder.build()?;
1094 log::debug!("request content: {:?}", local_req.body());
1095 let local_resp = local_client.execute(local_req).await?;
1096
1097 let local_status = local_resp.status();
1098 let local_content = local_resp.text().await?;
1099 log::debug!("response content: {}", local_content);
1100
1101 if !local_status.is_client_error() && !local_status.is_server_error() {
1102 match serde_json::from_str::<
1103 crate::datadogV2::model::ApplicationSecurityWafExclusionFiltersResponse,
1104 >(&local_content)
1105 {
1106 Ok(e) => {
1107 return Ok(datadog::ResponseContent {
1108 status: local_status,
1109 content: local_content,
1110 entity: Some(e),
1111 })
1112 }
1113 Err(e) => return Err(datadog::Error::Serde(e)),
1114 };
1115 } else {
1116 let local_entity: Option<ListApplicationSecurityWafExclusionFiltersError> =
1117 serde_json::from_str(&local_content).ok();
1118 let local_error = datadog::ResponseContent {
1119 status: local_status,
1120 content: local_content,
1121 entity: local_entity,
1122 };
1123 Err(datadog::Error::ResponseError(local_error))
1124 }
1125 }
1126
1127 pub async fn update_application_security_waf_custom_rule(
1130 &self,
1131 custom_rule_id: String,
1132 body: crate::datadogV2::model::ApplicationSecurityWafCustomRuleUpdateRequest,
1133 ) -> Result<
1134 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
1135 datadog::Error<UpdateApplicationSecurityWafCustomRuleError>,
1136 > {
1137 match self
1138 .update_application_security_waf_custom_rule_with_http_info(custom_rule_id, body)
1139 .await
1140 {
1141 Ok(response_content) => {
1142 if let Some(e) = response_content.entity {
1143 Ok(e)
1144 } else {
1145 Err(datadog::Error::Serde(serde::de::Error::custom(
1146 "response content was None",
1147 )))
1148 }
1149 }
1150 Err(err) => Err(err),
1151 }
1152 }
1153
1154 pub async fn update_application_security_waf_custom_rule_with_http_info(
1157 &self,
1158 custom_rule_id: String,
1159 body: crate::datadogV2::model::ApplicationSecurityWafCustomRuleUpdateRequest,
1160 ) -> Result<
1161 datadog::ResponseContent<crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse>,
1162 datadog::Error<UpdateApplicationSecurityWafCustomRuleError>,
1163 > {
1164 let local_configuration = &self.config;
1165 let operation_id = "v2.update_application_security_waf_custom_rule";
1166
1167 let local_client = &self.client;
1168
1169 let local_uri_str = format!(
1170 "{}/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}",
1171 local_configuration.get_operation_host(operation_id),
1172 custom_rule_id = datadog::urlencode(custom_rule_id)
1173 );
1174 let mut local_req_builder =
1175 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
1176
1177 let mut headers = HeaderMap::new();
1179 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1180 headers.insert("Accept", HeaderValue::from_static("application/json"));
1181
1182 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1184 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1185 Err(e) => {
1186 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1187 headers.insert(
1188 reqwest::header::USER_AGENT,
1189 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1190 )
1191 }
1192 };
1193
1194 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1196 headers.insert(
1197 "DD-API-KEY",
1198 HeaderValue::from_str(local_key.key.as_str())
1199 .expect("failed to parse DD-API-KEY header"),
1200 );
1201 };
1202 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1203 headers.insert(
1204 "DD-APPLICATION-KEY",
1205 HeaderValue::from_str(local_key.key.as_str())
1206 .expect("failed to parse DD-APPLICATION-KEY header"),
1207 );
1208 };
1209
1210 let output = Vec::new();
1212 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1213 if body.serialize(&mut ser).is_ok() {
1214 if let Some(content_encoding) = headers.get("Content-Encoding") {
1215 match content_encoding.to_str().unwrap_or_default() {
1216 "gzip" => {
1217 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1218 let _ = enc.write_all(ser.into_inner().as_slice());
1219 match enc.finish() {
1220 Ok(buf) => {
1221 local_req_builder = local_req_builder.body(buf);
1222 }
1223 Err(e) => return Err(datadog::Error::Io(e)),
1224 }
1225 }
1226 "deflate" => {
1227 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1228 let _ = enc.write_all(ser.into_inner().as_slice());
1229 match enc.finish() {
1230 Ok(buf) => {
1231 local_req_builder = local_req_builder.body(buf);
1232 }
1233 Err(e) => return Err(datadog::Error::Io(e)),
1234 }
1235 }
1236 "zstd1" => {
1237 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1238 let _ = enc.write_all(ser.into_inner().as_slice());
1239 match enc.finish() {
1240 Ok(buf) => {
1241 local_req_builder = local_req_builder.body(buf);
1242 }
1243 Err(e) => return Err(datadog::Error::Io(e)),
1244 }
1245 }
1246 _ => {
1247 local_req_builder = local_req_builder.body(ser.into_inner());
1248 }
1249 }
1250 } else {
1251 local_req_builder = local_req_builder.body(ser.into_inner());
1252 }
1253 }
1254
1255 local_req_builder = local_req_builder.headers(headers);
1256 let local_req = local_req_builder.build()?;
1257 log::debug!("request content: {:?}", local_req.body());
1258 let local_resp = local_client.execute(local_req).await?;
1259
1260 let local_status = local_resp.status();
1261 let local_content = local_resp.text().await?;
1262 log::debug!("response content: {}", local_content);
1263
1264 if !local_status.is_client_error() && !local_status.is_server_error() {
1265 match serde_json::from_str::<
1266 crate::datadogV2::model::ApplicationSecurityWafCustomRuleResponse,
1267 >(&local_content)
1268 {
1269 Ok(e) => {
1270 return Ok(datadog::ResponseContent {
1271 status: local_status,
1272 content: local_content,
1273 entity: Some(e),
1274 })
1275 }
1276 Err(e) => return Err(datadog::Error::Serde(e)),
1277 };
1278 } else {
1279 let local_entity: Option<UpdateApplicationSecurityWafCustomRuleError> =
1280 serde_json::from_str(&local_content).ok();
1281 let local_error = datadog::ResponseContent {
1282 status: local_status,
1283 content: local_content,
1284 entity: local_entity,
1285 };
1286 Err(datadog::Error::ResponseError(local_error))
1287 }
1288 }
1289
1290 pub async fn update_application_security_waf_exclusion_filter(
1293 &self,
1294 exclusion_filter_id: String,
1295 body: crate::datadogV2::model::ApplicationSecurityWafExclusionFilterUpdateRequest,
1296 ) -> Result<
1297 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
1298 datadog::Error<UpdateApplicationSecurityWafExclusionFilterError>,
1299 > {
1300 match self
1301 .update_application_security_waf_exclusion_filter_with_http_info(
1302 exclusion_filter_id,
1303 body,
1304 )
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_application_security_waf_exclusion_filter_with_http_info(
1323 &self,
1324 exclusion_filter_id: String,
1325 body: crate::datadogV2::model::ApplicationSecurityWafExclusionFilterUpdateRequest,
1326 ) -> Result<
1327 datadog::ResponseContent<
1328 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
1329 >,
1330 datadog::Error<UpdateApplicationSecurityWafExclusionFilterError>,
1331 > {
1332 let local_configuration = &self.config;
1333 let operation_id = "v2.update_application_security_waf_exclusion_filter";
1334
1335 let local_client = &self.client;
1336
1337 let local_uri_str = format!(
1338 "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}",
1339 local_configuration.get_operation_host(operation_id),
1340 exclusion_filter_id = datadog::urlencode(exclusion_filter_id)
1341 );
1342 let mut local_req_builder =
1343 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
1344
1345 let mut headers = HeaderMap::new();
1347 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1348 headers.insert("Accept", HeaderValue::from_static("application/json"));
1349
1350 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1352 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1353 Err(e) => {
1354 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1355 headers.insert(
1356 reqwest::header::USER_AGENT,
1357 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1358 )
1359 }
1360 };
1361
1362 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1364 headers.insert(
1365 "DD-API-KEY",
1366 HeaderValue::from_str(local_key.key.as_str())
1367 .expect("failed to parse DD-API-KEY header"),
1368 );
1369 };
1370 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1371 headers.insert(
1372 "DD-APPLICATION-KEY",
1373 HeaderValue::from_str(local_key.key.as_str())
1374 .expect("failed to parse DD-APPLICATION-KEY header"),
1375 );
1376 };
1377
1378 let output = Vec::new();
1380 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1381 if body.serialize(&mut ser).is_ok() {
1382 if let Some(content_encoding) = headers.get("Content-Encoding") {
1383 match content_encoding.to_str().unwrap_or_default() {
1384 "gzip" => {
1385 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1386 let _ = enc.write_all(ser.into_inner().as_slice());
1387 match enc.finish() {
1388 Ok(buf) => {
1389 local_req_builder = local_req_builder.body(buf);
1390 }
1391 Err(e) => return Err(datadog::Error::Io(e)),
1392 }
1393 }
1394 "deflate" => {
1395 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1396 let _ = enc.write_all(ser.into_inner().as_slice());
1397 match enc.finish() {
1398 Ok(buf) => {
1399 local_req_builder = local_req_builder.body(buf);
1400 }
1401 Err(e) => return Err(datadog::Error::Io(e)),
1402 }
1403 }
1404 "zstd1" => {
1405 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1406 let _ = enc.write_all(ser.into_inner().as_slice());
1407 match enc.finish() {
1408 Ok(buf) => {
1409 local_req_builder = local_req_builder.body(buf);
1410 }
1411 Err(e) => return Err(datadog::Error::Io(e)),
1412 }
1413 }
1414 _ => {
1415 local_req_builder = local_req_builder.body(ser.into_inner());
1416 }
1417 }
1418 } else {
1419 local_req_builder = local_req_builder.body(ser.into_inner());
1420 }
1421 }
1422
1423 local_req_builder = local_req_builder.headers(headers);
1424 let local_req = local_req_builder.build()?;
1425 log::debug!("request content: {:?}", local_req.body());
1426 let local_resp = local_client.execute(local_req).await?;
1427
1428 let local_status = local_resp.status();
1429 let local_content = local_resp.text().await?;
1430 log::debug!("response content: {}", local_content);
1431
1432 if !local_status.is_client_error() && !local_status.is_server_error() {
1433 match serde_json::from_str::<
1434 crate::datadogV2::model::ApplicationSecurityWafExclusionFilterResponse,
1435 >(&local_content)
1436 {
1437 Ok(e) => {
1438 return Ok(datadog::ResponseContent {
1439 status: local_status,
1440 content: local_content,
1441 entity: Some(e),
1442 })
1443 }
1444 Err(e) => return Err(datadog::Error::Serde(e)),
1445 };
1446 } else {
1447 let local_entity: Option<UpdateApplicationSecurityWafExclusionFilterError> =
1448 serde_json::from_str(&local_content).ok();
1449 let local_error = datadog::ResponseContent {
1450 status: local_status,
1451 content: local_content,
1452 entity: local_entity,
1453 };
1454 Err(datadog::Error::ResponseError(local_error))
1455 }
1456 }
1457}