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