datadog_api_client/datadogV2/api/
api_case_management.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use crate::datadog;
5use async_stream::try_stream;
6use flate2::{
7    write::{GzEncoder, ZlibEncoder},
8    Compression,
9};
10use futures_core::stream::Stream;
11use reqwest::header::{HeaderMap, HeaderValue};
12use serde::{Deserialize, Serialize};
13use std::io::Write;
14
15/// SearchCasesOptionalParams is a struct for passing parameters to the method [`CaseManagementAPI::search_cases`]
16#[non_exhaustive]
17#[derive(Clone, Default, Debug)]
18pub struct SearchCasesOptionalParams {
19    /// Size for a given page. The maximum allowed value is 100.
20    pub page_size: Option<i64>,
21    /// Specific page number to return.
22    pub page_number: Option<i64>,
23    /// Specify which field to sort
24    pub sort_field: Option<crate::datadogV2::model::CaseSortableField>,
25    /// Search query
26    pub filter: Option<String>,
27    /// Specify if order is ascending or not
28    pub sort_asc: Option<bool>,
29}
30
31impl SearchCasesOptionalParams {
32    /// Size for a given page. The maximum allowed value is 100.
33    pub fn page_size(mut self, value: i64) -> Self {
34        self.page_size = Some(value);
35        self
36    }
37    /// Specific page number to return.
38    pub fn page_number(mut self, value: i64) -> Self {
39        self.page_number = Some(value);
40        self
41    }
42    /// Specify which field to sort
43    pub fn sort_field(mut self, value: crate::datadogV2::model::CaseSortableField) -> Self {
44        self.sort_field = Some(value);
45        self
46    }
47    /// Search query
48    pub fn filter(mut self, value: String) -> Self {
49        self.filter = Some(value);
50        self
51    }
52    /// Specify if order is ascending or not
53    pub fn sort_asc(mut self, value: bool) -> Self {
54        self.sort_asc = Some(value);
55        self
56    }
57}
58
59/// ArchiveCaseError is a struct for typed errors of method [`CaseManagementAPI::archive_case`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum ArchiveCaseError {
63    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
64    UnknownValue(serde_json::Value),
65}
66
67/// AssignCaseError is a struct for typed errors of method [`CaseManagementAPI::assign_case`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum AssignCaseError {
71    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
72    UnknownValue(serde_json::Value),
73}
74
75/// CreateCaseError is a struct for typed errors of method [`CaseManagementAPI::create_case`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum CreateCaseError {
79    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
80    UnknownValue(serde_json::Value),
81}
82
83/// CreateProjectError is a struct for typed errors of method [`CaseManagementAPI::create_project`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum CreateProjectError {
87    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
88    UnknownValue(serde_json::Value),
89}
90
91/// DeleteProjectError is a struct for typed errors of method [`CaseManagementAPI::delete_project`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum DeleteProjectError {
95    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
96    UnknownValue(serde_json::Value),
97}
98
99/// GetCaseError is a struct for typed errors of method [`CaseManagementAPI::get_case`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum GetCaseError {
103    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
104    UnknownValue(serde_json::Value),
105}
106
107/// GetProjectError is a struct for typed errors of method [`CaseManagementAPI::get_project`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum GetProjectError {
111    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
112    UnknownValue(serde_json::Value),
113}
114
115/// GetProjectsError is a struct for typed errors of method [`CaseManagementAPI::get_projects`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum GetProjectsError {
119    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
120    UnknownValue(serde_json::Value),
121}
122
123/// SearchCasesError is a struct for typed errors of method [`CaseManagementAPI::search_cases`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum SearchCasesError {
127    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
128    UnknownValue(serde_json::Value),
129}
130
131/// UnarchiveCaseError is a struct for typed errors of method [`CaseManagementAPI::unarchive_case`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum UnarchiveCaseError {
135    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
136    UnknownValue(serde_json::Value),
137}
138
139/// UnassignCaseError is a struct for typed errors of method [`CaseManagementAPI::unassign_case`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum UnassignCaseError {
143    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
144    UnknownValue(serde_json::Value),
145}
146
147/// UpdatePriorityError is a struct for typed errors of method [`CaseManagementAPI::update_priority`]
148#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum UpdatePriorityError {
151    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
152    UnknownValue(serde_json::Value),
153}
154
155/// UpdateStatusError is a struct for typed errors of method [`CaseManagementAPI::update_status`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum UpdateStatusError {
159    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
160    UnknownValue(serde_json::Value),
161}
162
163/// View and manage cases and projects within Case Management. See the [Case Management page](<https://docs.datadoghq.com/service_management/case_management/>) for more information.
164#[derive(Debug, Clone)]
165pub struct CaseManagementAPI {
166    config: datadog::Configuration,
167    client: reqwest_middleware::ClientWithMiddleware,
168}
169
170impl Default for CaseManagementAPI {
171    fn default() -> Self {
172        Self::with_config(datadog::Configuration::default())
173    }
174}
175
176impl CaseManagementAPI {
177    pub fn new() -> Self {
178        Self::default()
179    }
180    pub fn with_config(config: datadog::Configuration) -> Self {
181        let mut reqwest_client_builder = reqwest::Client::builder();
182
183        if let Some(proxy_url) = &config.proxy_url {
184            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
185            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
186        }
187
188        let mut middleware_client_builder =
189            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
190
191        if config.enable_retry {
192            struct RetryableStatus;
193            impl reqwest_retry::RetryableStrategy for RetryableStatus {
194                fn handle(
195                    &self,
196                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
197                ) -> Option<reqwest_retry::Retryable> {
198                    match res {
199                        Ok(success) => reqwest_retry::default_on_request_success(success),
200                        Err(_) => None,
201                    }
202                }
203            }
204            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
205                .build_with_max_retries(config.max_retries);
206
207            let retry_middleware =
208                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
209                    backoff_policy,
210                    RetryableStatus,
211                );
212
213            middleware_client_builder = middleware_client_builder.with(retry_middleware);
214        }
215
216        let client = middleware_client_builder.build();
217
218        Self { config, client }
219    }
220
221    pub fn with_client_and_config(
222        config: datadog::Configuration,
223        client: reqwest_middleware::ClientWithMiddleware,
224    ) -> Self {
225        Self { config, client }
226    }
227
228    /// Archive case
229    pub async fn archive_case(
230        &self,
231        case_id: String,
232        body: crate::datadogV2::model::CaseEmptyRequest,
233    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<ArchiveCaseError>> {
234        match self.archive_case_with_http_info(case_id, body).await {
235            Ok(response_content) => {
236                if let Some(e) = response_content.entity {
237                    Ok(e)
238                } else {
239                    Err(datadog::Error::Serde(serde::de::Error::custom(
240                        "response content was None",
241                    )))
242                }
243            }
244            Err(err) => Err(err),
245        }
246    }
247
248    /// Archive case
249    pub async fn archive_case_with_http_info(
250        &self,
251        case_id: String,
252        body: crate::datadogV2::model::CaseEmptyRequest,
253    ) -> Result<
254        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
255        datadog::Error<ArchiveCaseError>,
256    > {
257        let local_configuration = &self.config;
258        let operation_id = "v2.archive_case";
259
260        let local_client = &self.client;
261
262        let local_uri_str = format!(
263            "{}/api/v2/cases/{case_id}/archive",
264            local_configuration.get_operation_host(operation_id),
265            case_id = datadog::urlencode(case_id)
266        );
267        let mut local_req_builder =
268            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
269
270        // build headers
271        let mut headers = HeaderMap::new();
272        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
273        headers.insert("Accept", HeaderValue::from_static("application/json"));
274
275        // build user agent
276        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
277            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
278            Err(e) => {
279                log::warn!("Failed to parse user agent header: {e}, falling back to default");
280                headers.insert(
281                    reqwest::header::USER_AGENT,
282                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
283                )
284            }
285        };
286
287        // build auth
288        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
289            headers.insert(
290                "DD-API-KEY",
291                HeaderValue::from_str(local_key.key.as_str())
292                    .expect("failed to parse DD-API-KEY header"),
293            );
294        };
295        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
296            headers.insert(
297                "DD-APPLICATION-KEY",
298                HeaderValue::from_str(local_key.key.as_str())
299                    .expect("failed to parse DD-APPLICATION-KEY header"),
300            );
301        };
302
303        // build body parameters
304        let output = Vec::new();
305        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
306        if body.serialize(&mut ser).is_ok() {
307            if let Some(content_encoding) = headers.get("Content-Encoding") {
308                match content_encoding.to_str().unwrap_or_default() {
309                    "gzip" => {
310                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
311                        let _ = enc.write_all(ser.into_inner().as_slice());
312                        match enc.finish() {
313                            Ok(buf) => {
314                                local_req_builder = local_req_builder.body(buf);
315                            }
316                            Err(e) => return Err(datadog::Error::Io(e)),
317                        }
318                    }
319                    "deflate" => {
320                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
321                        let _ = enc.write_all(ser.into_inner().as_slice());
322                        match enc.finish() {
323                            Ok(buf) => {
324                                local_req_builder = local_req_builder.body(buf);
325                            }
326                            Err(e) => return Err(datadog::Error::Io(e)),
327                        }
328                    }
329                    "zstd1" => {
330                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
331                        let _ = enc.write_all(ser.into_inner().as_slice());
332                        match enc.finish() {
333                            Ok(buf) => {
334                                local_req_builder = local_req_builder.body(buf);
335                            }
336                            Err(e) => return Err(datadog::Error::Io(e)),
337                        }
338                    }
339                    _ => {
340                        local_req_builder = local_req_builder.body(ser.into_inner());
341                    }
342                }
343            } else {
344                local_req_builder = local_req_builder.body(ser.into_inner());
345            }
346        }
347
348        local_req_builder = local_req_builder.headers(headers);
349        let local_req = local_req_builder.build()?;
350        log::debug!("request content: {:?}", local_req.body());
351        let local_resp = local_client.execute(local_req).await?;
352
353        let local_status = local_resp.status();
354        let local_content = local_resp.text().await?;
355        log::debug!("response content: {}", local_content);
356
357        if !local_status.is_client_error() && !local_status.is_server_error() {
358            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
359                Ok(e) => {
360                    return Ok(datadog::ResponseContent {
361                        status: local_status,
362                        content: local_content,
363                        entity: Some(e),
364                    })
365                }
366                Err(e) => return Err(datadog::Error::Serde(e)),
367            };
368        } else {
369            let local_entity: Option<ArchiveCaseError> = serde_json::from_str(&local_content).ok();
370            let local_error = datadog::ResponseContent {
371                status: local_status,
372                content: local_content,
373                entity: local_entity,
374            };
375            Err(datadog::Error::ResponseError(local_error))
376        }
377    }
378
379    /// Assign case to a user
380    pub async fn assign_case(
381        &self,
382        case_id: String,
383        body: crate::datadogV2::model::CaseAssignRequest,
384    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<AssignCaseError>> {
385        match self.assign_case_with_http_info(case_id, body).await {
386            Ok(response_content) => {
387                if let Some(e) = response_content.entity {
388                    Ok(e)
389                } else {
390                    Err(datadog::Error::Serde(serde::de::Error::custom(
391                        "response content was None",
392                    )))
393                }
394            }
395            Err(err) => Err(err),
396        }
397    }
398
399    /// Assign case to a user
400    pub async fn assign_case_with_http_info(
401        &self,
402        case_id: String,
403        body: crate::datadogV2::model::CaseAssignRequest,
404    ) -> Result<
405        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
406        datadog::Error<AssignCaseError>,
407    > {
408        let local_configuration = &self.config;
409        let operation_id = "v2.assign_case";
410
411        let local_client = &self.client;
412
413        let local_uri_str = format!(
414            "{}/api/v2/cases/{case_id}/assign",
415            local_configuration.get_operation_host(operation_id),
416            case_id = datadog::urlencode(case_id)
417        );
418        let mut local_req_builder =
419            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
420
421        // build headers
422        let mut headers = HeaderMap::new();
423        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
424        headers.insert("Accept", HeaderValue::from_static("application/json"));
425
426        // build user agent
427        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
428            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
429            Err(e) => {
430                log::warn!("Failed to parse user agent header: {e}, falling back to default");
431                headers.insert(
432                    reqwest::header::USER_AGENT,
433                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
434                )
435            }
436        };
437
438        // build auth
439        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
440            headers.insert(
441                "DD-API-KEY",
442                HeaderValue::from_str(local_key.key.as_str())
443                    .expect("failed to parse DD-API-KEY header"),
444            );
445        };
446        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
447            headers.insert(
448                "DD-APPLICATION-KEY",
449                HeaderValue::from_str(local_key.key.as_str())
450                    .expect("failed to parse DD-APPLICATION-KEY header"),
451            );
452        };
453
454        // build body parameters
455        let output = Vec::new();
456        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
457        if body.serialize(&mut ser).is_ok() {
458            if let Some(content_encoding) = headers.get("Content-Encoding") {
459                match content_encoding.to_str().unwrap_or_default() {
460                    "gzip" => {
461                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
462                        let _ = enc.write_all(ser.into_inner().as_slice());
463                        match enc.finish() {
464                            Ok(buf) => {
465                                local_req_builder = local_req_builder.body(buf);
466                            }
467                            Err(e) => return Err(datadog::Error::Io(e)),
468                        }
469                    }
470                    "deflate" => {
471                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
472                        let _ = enc.write_all(ser.into_inner().as_slice());
473                        match enc.finish() {
474                            Ok(buf) => {
475                                local_req_builder = local_req_builder.body(buf);
476                            }
477                            Err(e) => return Err(datadog::Error::Io(e)),
478                        }
479                    }
480                    "zstd1" => {
481                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
482                        let _ = enc.write_all(ser.into_inner().as_slice());
483                        match enc.finish() {
484                            Ok(buf) => {
485                                local_req_builder = local_req_builder.body(buf);
486                            }
487                            Err(e) => return Err(datadog::Error::Io(e)),
488                        }
489                    }
490                    _ => {
491                        local_req_builder = local_req_builder.body(ser.into_inner());
492                    }
493                }
494            } else {
495                local_req_builder = local_req_builder.body(ser.into_inner());
496            }
497        }
498
499        local_req_builder = local_req_builder.headers(headers);
500        let local_req = local_req_builder.build()?;
501        log::debug!("request content: {:?}", local_req.body());
502        let local_resp = local_client.execute(local_req).await?;
503
504        let local_status = local_resp.status();
505        let local_content = local_resp.text().await?;
506        log::debug!("response content: {}", local_content);
507
508        if !local_status.is_client_error() && !local_status.is_server_error() {
509            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
510                Ok(e) => {
511                    return Ok(datadog::ResponseContent {
512                        status: local_status,
513                        content: local_content,
514                        entity: Some(e),
515                    })
516                }
517                Err(e) => return Err(datadog::Error::Serde(e)),
518            };
519        } else {
520            let local_entity: Option<AssignCaseError> = serde_json::from_str(&local_content).ok();
521            let local_error = datadog::ResponseContent {
522                status: local_status,
523                content: local_content,
524                entity: local_entity,
525            };
526            Err(datadog::Error::ResponseError(local_error))
527        }
528    }
529
530    /// Create a Case
531    pub async fn create_case(
532        &self,
533        body: crate::datadogV2::model::CaseCreateRequest,
534    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<CreateCaseError>> {
535        match self.create_case_with_http_info(body).await {
536            Ok(response_content) => {
537                if let Some(e) = response_content.entity {
538                    Ok(e)
539                } else {
540                    Err(datadog::Error::Serde(serde::de::Error::custom(
541                        "response content was None",
542                    )))
543                }
544            }
545            Err(err) => Err(err),
546        }
547    }
548
549    /// Create a Case
550    pub async fn create_case_with_http_info(
551        &self,
552        body: crate::datadogV2::model::CaseCreateRequest,
553    ) -> Result<
554        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
555        datadog::Error<CreateCaseError>,
556    > {
557        let local_configuration = &self.config;
558        let operation_id = "v2.create_case";
559
560        let local_client = &self.client;
561
562        let local_uri_str = format!(
563            "{}/api/v2/cases",
564            local_configuration.get_operation_host(operation_id)
565        );
566        let mut local_req_builder =
567            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
568
569        // build headers
570        let mut headers = HeaderMap::new();
571        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
572        headers.insert("Accept", HeaderValue::from_static("application/json"));
573
574        // build user agent
575        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
576            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
577            Err(e) => {
578                log::warn!("Failed to parse user agent header: {e}, falling back to default");
579                headers.insert(
580                    reqwest::header::USER_AGENT,
581                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
582                )
583            }
584        };
585
586        // build auth
587        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
588            headers.insert(
589                "DD-API-KEY",
590                HeaderValue::from_str(local_key.key.as_str())
591                    .expect("failed to parse DD-API-KEY header"),
592            );
593        };
594        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
595            headers.insert(
596                "DD-APPLICATION-KEY",
597                HeaderValue::from_str(local_key.key.as_str())
598                    .expect("failed to parse DD-APPLICATION-KEY header"),
599            );
600        };
601
602        // build body parameters
603        let output = Vec::new();
604        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
605        if body.serialize(&mut ser).is_ok() {
606            if let Some(content_encoding) = headers.get("Content-Encoding") {
607                match content_encoding.to_str().unwrap_or_default() {
608                    "gzip" => {
609                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
610                        let _ = enc.write_all(ser.into_inner().as_slice());
611                        match enc.finish() {
612                            Ok(buf) => {
613                                local_req_builder = local_req_builder.body(buf);
614                            }
615                            Err(e) => return Err(datadog::Error::Io(e)),
616                        }
617                    }
618                    "deflate" => {
619                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
620                        let _ = enc.write_all(ser.into_inner().as_slice());
621                        match enc.finish() {
622                            Ok(buf) => {
623                                local_req_builder = local_req_builder.body(buf);
624                            }
625                            Err(e) => return Err(datadog::Error::Io(e)),
626                        }
627                    }
628                    "zstd1" => {
629                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
630                        let _ = enc.write_all(ser.into_inner().as_slice());
631                        match enc.finish() {
632                            Ok(buf) => {
633                                local_req_builder = local_req_builder.body(buf);
634                            }
635                            Err(e) => return Err(datadog::Error::Io(e)),
636                        }
637                    }
638                    _ => {
639                        local_req_builder = local_req_builder.body(ser.into_inner());
640                    }
641                }
642            } else {
643                local_req_builder = local_req_builder.body(ser.into_inner());
644            }
645        }
646
647        local_req_builder = local_req_builder.headers(headers);
648        let local_req = local_req_builder.build()?;
649        log::debug!("request content: {:?}", local_req.body());
650        let local_resp = local_client.execute(local_req).await?;
651
652        let local_status = local_resp.status();
653        let local_content = local_resp.text().await?;
654        log::debug!("response content: {}", local_content);
655
656        if !local_status.is_client_error() && !local_status.is_server_error() {
657            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
658                Ok(e) => {
659                    return Ok(datadog::ResponseContent {
660                        status: local_status,
661                        content: local_content,
662                        entity: Some(e),
663                    })
664                }
665                Err(e) => return Err(datadog::Error::Serde(e)),
666            };
667        } else {
668            let local_entity: Option<CreateCaseError> = serde_json::from_str(&local_content).ok();
669            let local_error = datadog::ResponseContent {
670                status: local_status,
671                content: local_content,
672                entity: local_entity,
673            };
674            Err(datadog::Error::ResponseError(local_error))
675        }
676    }
677
678    /// Create a project.
679    pub async fn create_project(
680        &self,
681        body: crate::datadogV2::model::ProjectCreateRequest,
682    ) -> Result<crate::datadogV2::model::ProjectResponse, datadog::Error<CreateProjectError>> {
683        match self.create_project_with_http_info(body).await {
684            Ok(response_content) => {
685                if let Some(e) = response_content.entity {
686                    Ok(e)
687                } else {
688                    Err(datadog::Error::Serde(serde::de::Error::custom(
689                        "response content was None",
690                    )))
691                }
692            }
693            Err(err) => Err(err),
694        }
695    }
696
697    /// Create a project.
698    pub async fn create_project_with_http_info(
699        &self,
700        body: crate::datadogV2::model::ProjectCreateRequest,
701    ) -> Result<
702        datadog::ResponseContent<crate::datadogV2::model::ProjectResponse>,
703        datadog::Error<CreateProjectError>,
704    > {
705        let local_configuration = &self.config;
706        let operation_id = "v2.create_project";
707
708        let local_client = &self.client;
709
710        let local_uri_str = format!(
711            "{}/api/v2/cases/projects",
712            local_configuration.get_operation_host(operation_id)
713        );
714        let mut local_req_builder =
715            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
716
717        // build headers
718        let mut headers = HeaderMap::new();
719        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
720        headers.insert("Accept", HeaderValue::from_static("application/json"));
721
722        // build user agent
723        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
724            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
725            Err(e) => {
726                log::warn!("Failed to parse user agent header: {e}, falling back to default");
727                headers.insert(
728                    reqwest::header::USER_AGENT,
729                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
730                )
731            }
732        };
733
734        // build auth
735        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
736            headers.insert(
737                "DD-API-KEY",
738                HeaderValue::from_str(local_key.key.as_str())
739                    .expect("failed to parse DD-API-KEY header"),
740            );
741        };
742        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
743            headers.insert(
744                "DD-APPLICATION-KEY",
745                HeaderValue::from_str(local_key.key.as_str())
746                    .expect("failed to parse DD-APPLICATION-KEY header"),
747            );
748        };
749
750        // build body parameters
751        let output = Vec::new();
752        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
753        if body.serialize(&mut ser).is_ok() {
754            if let Some(content_encoding) = headers.get("Content-Encoding") {
755                match content_encoding.to_str().unwrap_or_default() {
756                    "gzip" => {
757                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
758                        let _ = enc.write_all(ser.into_inner().as_slice());
759                        match enc.finish() {
760                            Ok(buf) => {
761                                local_req_builder = local_req_builder.body(buf);
762                            }
763                            Err(e) => return Err(datadog::Error::Io(e)),
764                        }
765                    }
766                    "deflate" => {
767                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
768                        let _ = enc.write_all(ser.into_inner().as_slice());
769                        match enc.finish() {
770                            Ok(buf) => {
771                                local_req_builder = local_req_builder.body(buf);
772                            }
773                            Err(e) => return Err(datadog::Error::Io(e)),
774                        }
775                    }
776                    "zstd1" => {
777                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
778                        let _ = enc.write_all(ser.into_inner().as_slice());
779                        match enc.finish() {
780                            Ok(buf) => {
781                                local_req_builder = local_req_builder.body(buf);
782                            }
783                            Err(e) => return Err(datadog::Error::Io(e)),
784                        }
785                    }
786                    _ => {
787                        local_req_builder = local_req_builder.body(ser.into_inner());
788                    }
789                }
790            } else {
791                local_req_builder = local_req_builder.body(ser.into_inner());
792            }
793        }
794
795        local_req_builder = local_req_builder.headers(headers);
796        let local_req = local_req_builder.build()?;
797        log::debug!("request content: {:?}", local_req.body());
798        let local_resp = local_client.execute(local_req).await?;
799
800        let local_status = local_resp.status();
801        let local_content = local_resp.text().await?;
802        log::debug!("response content: {}", local_content);
803
804        if !local_status.is_client_error() && !local_status.is_server_error() {
805            match serde_json::from_str::<crate::datadogV2::model::ProjectResponse>(&local_content) {
806                Ok(e) => {
807                    return Ok(datadog::ResponseContent {
808                        status: local_status,
809                        content: local_content,
810                        entity: Some(e),
811                    })
812                }
813                Err(e) => return Err(datadog::Error::Serde(e)),
814            };
815        } else {
816            let local_entity: Option<CreateProjectError> =
817                serde_json::from_str(&local_content).ok();
818            let local_error = datadog::ResponseContent {
819                status: local_status,
820                content: local_content,
821                entity: local_entity,
822            };
823            Err(datadog::Error::ResponseError(local_error))
824        }
825    }
826
827    /// Remove a project using the project's `id`.
828    pub async fn delete_project(
829        &self,
830        project_id: String,
831    ) -> Result<(), datadog::Error<DeleteProjectError>> {
832        match self.delete_project_with_http_info(project_id).await {
833            Ok(_) => Ok(()),
834            Err(err) => Err(err),
835        }
836    }
837
838    /// Remove a project using the project's `id`.
839    pub async fn delete_project_with_http_info(
840        &self,
841        project_id: String,
842    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteProjectError>> {
843        let local_configuration = &self.config;
844        let operation_id = "v2.delete_project";
845
846        let local_client = &self.client;
847
848        let local_uri_str = format!(
849            "{}/api/v2/cases/projects/{project_id}",
850            local_configuration.get_operation_host(operation_id),
851            project_id = datadog::urlencode(project_id)
852        );
853        let mut local_req_builder =
854            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
855
856        // build headers
857        let mut headers = HeaderMap::new();
858        headers.insert("Accept", HeaderValue::from_static("*/*"));
859
860        // build user agent
861        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
862            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
863            Err(e) => {
864                log::warn!("Failed to parse user agent header: {e}, falling back to default");
865                headers.insert(
866                    reqwest::header::USER_AGENT,
867                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
868                )
869            }
870        };
871
872        // build auth
873        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
874            headers.insert(
875                "DD-API-KEY",
876                HeaderValue::from_str(local_key.key.as_str())
877                    .expect("failed to parse DD-API-KEY header"),
878            );
879        };
880        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
881            headers.insert(
882                "DD-APPLICATION-KEY",
883                HeaderValue::from_str(local_key.key.as_str())
884                    .expect("failed to parse DD-APPLICATION-KEY header"),
885            );
886        };
887
888        local_req_builder = local_req_builder.headers(headers);
889        let local_req = local_req_builder.build()?;
890        log::debug!("request content: {:?}", local_req.body());
891        let local_resp = local_client.execute(local_req).await?;
892
893        let local_status = local_resp.status();
894        let local_content = local_resp.text().await?;
895        log::debug!("response content: {}", local_content);
896
897        if !local_status.is_client_error() && !local_status.is_server_error() {
898            Ok(datadog::ResponseContent {
899                status: local_status,
900                content: local_content,
901                entity: None,
902            })
903        } else {
904            let local_entity: Option<DeleteProjectError> =
905                serde_json::from_str(&local_content).ok();
906            let local_error = datadog::ResponseContent {
907                status: local_status,
908                content: local_content,
909                entity: local_entity,
910            };
911            Err(datadog::Error::ResponseError(local_error))
912        }
913    }
914
915    /// Get the details of case by `case_id`
916    pub async fn get_case(
917        &self,
918        case_id: String,
919    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<GetCaseError>> {
920        match self.get_case_with_http_info(case_id).await {
921            Ok(response_content) => {
922                if let Some(e) = response_content.entity {
923                    Ok(e)
924                } else {
925                    Err(datadog::Error::Serde(serde::de::Error::custom(
926                        "response content was None",
927                    )))
928                }
929            }
930            Err(err) => Err(err),
931        }
932    }
933
934    /// Get the details of case by `case_id`
935    pub async fn get_case_with_http_info(
936        &self,
937        case_id: String,
938    ) -> Result<
939        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
940        datadog::Error<GetCaseError>,
941    > {
942        let local_configuration = &self.config;
943        let operation_id = "v2.get_case";
944
945        let local_client = &self.client;
946
947        let local_uri_str = format!(
948            "{}/api/v2/cases/{case_id}",
949            local_configuration.get_operation_host(operation_id),
950            case_id = datadog::urlencode(case_id)
951        );
952        let mut local_req_builder =
953            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
954
955        // build headers
956        let mut headers = HeaderMap::new();
957        headers.insert("Accept", HeaderValue::from_static("application/json"));
958
959        // build user agent
960        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
961            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
962            Err(e) => {
963                log::warn!("Failed to parse user agent header: {e}, falling back to default");
964                headers.insert(
965                    reqwest::header::USER_AGENT,
966                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
967                )
968            }
969        };
970
971        // build auth
972        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
973            headers.insert(
974                "DD-API-KEY",
975                HeaderValue::from_str(local_key.key.as_str())
976                    .expect("failed to parse DD-API-KEY header"),
977            );
978        };
979        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
980            headers.insert(
981                "DD-APPLICATION-KEY",
982                HeaderValue::from_str(local_key.key.as_str())
983                    .expect("failed to parse DD-APPLICATION-KEY header"),
984            );
985        };
986
987        local_req_builder = local_req_builder.headers(headers);
988        let local_req = local_req_builder.build()?;
989        log::debug!("request content: {:?}", local_req.body());
990        let local_resp = local_client.execute(local_req).await?;
991
992        let local_status = local_resp.status();
993        let local_content = local_resp.text().await?;
994        log::debug!("response content: {}", local_content);
995
996        if !local_status.is_client_error() && !local_status.is_server_error() {
997            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
998                Ok(e) => {
999                    return Ok(datadog::ResponseContent {
1000                        status: local_status,
1001                        content: local_content,
1002                        entity: Some(e),
1003                    })
1004                }
1005                Err(e) => return Err(datadog::Error::Serde(e)),
1006            };
1007        } else {
1008            let local_entity: Option<GetCaseError> = serde_json::from_str(&local_content).ok();
1009            let local_error = datadog::ResponseContent {
1010                status: local_status,
1011                content: local_content,
1012                entity: local_entity,
1013            };
1014            Err(datadog::Error::ResponseError(local_error))
1015        }
1016    }
1017
1018    /// Get the details of a project by `project_id`.
1019    pub async fn get_project(
1020        &self,
1021        project_id: String,
1022    ) -> Result<crate::datadogV2::model::ProjectResponse, datadog::Error<GetProjectError>> {
1023        match self.get_project_with_http_info(project_id).await {
1024            Ok(response_content) => {
1025                if let Some(e) = response_content.entity {
1026                    Ok(e)
1027                } else {
1028                    Err(datadog::Error::Serde(serde::de::Error::custom(
1029                        "response content was None",
1030                    )))
1031                }
1032            }
1033            Err(err) => Err(err),
1034        }
1035    }
1036
1037    /// Get the details of a project by `project_id`.
1038    pub async fn get_project_with_http_info(
1039        &self,
1040        project_id: String,
1041    ) -> Result<
1042        datadog::ResponseContent<crate::datadogV2::model::ProjectResponse>,
1043        datadog::Error<GetProjectError>,
1044    > {
1045        let local_configuration = &self.config;
1046        let operation_id = "v2.get_project";
1047
1048        let local_client = &self.client;
1049
1050        let local_uri_str = format!(
1051            "{}/api/v2/cases/projects/{project_id}",
1052            local_configuration.get_operation_host(operation_id),
1053            project_id = datadog::urlencode(project_id)
1054        );
1055        let mut local_req_builder =
1056            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1057
1058        // build headers
1059        let mut headers = HeaderMap::new();
1060        headers.insert("Accept", HeaderValue::from_static("application/json"));
1061
1062        // build user agent
1063        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1064            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1065            Err(e) => {
1066                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1067                headers.insert(
1068                    reqwest::header::USER_AGENT,
1069                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1070                )
1071            }
1072        };
1073
1074        // build auth
1075        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1076            headers.insert(
1077                "DD-API-KEY",
1078                HeaderValue::from_str(local_key.key.as_str())
1079                    .expect("failed to parse DD-API-KEY header"),
1080            );
1081        };
1082        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1083            headers.insert(
1084                "DD-APPLICATION-KEY",
1085                HeaderValue::from_str(local_key.key.as_str())
1086                    .expect("failed to parse DD-APPLICATION-KEY header"),
1087            );
1088        };
1089
1090        local_req_builder = local_req_builder.headers(headers);
1091        let local_req = local_req_builder.build()?;
1092        log::debug!("request content: {:?}", local_req.body());
1093        let local_resp = local_client.execute(local_req).await?;
1094
1095        let local_status = local_resp.status();
1096        let local_content = local_resp.text().await?;
1097        log::debug!("response content: {}", local_content);
1098
1099        if !local_status.is_client_error() && !local_status.is_server_error() {
1100            match serde_json::from_str::<crate::datadogV2::model::ProjectResponse>(&local_content) {
1101                Ok(e) => {
1102                    return Ok(datadog::ResponseContent {
1103                        status: local_status,
1104                        content: local_content,
1105                        entity: Some(e),
1106                    })
1107                }
1108                Err(e) => return Err(datadog::Error::Serde(e)),
1109            };
1110        } else {
1111            let local_entity: Option<GetProjectError> = serde_json::from_str(&local_content).ok();
1112            let local_error = datadog::ResponseContent {
1113                status: local_status,
1114                content: local_content,
1115                entity: local_entity,
1116            };
1117            Err(datadog::Error::ResponseError(local_error))
1118        }
1119    }
1120
1121    /// Get all projects.
1122    pub async fn get_projects(
1123        &self,
1124    ) -> Result<crate::datadogV2::model::ProjectsResponse, datadog::Error<GetProjectsError>> {
1125        match self.get_projects_with_http_info().await {
1126            Ok(response_content) => {
1127                if let Some(e) = response_content.entity {
1128                    Ok(e)
1129                } else {
1130                    Err(datadog::Error::Serde(serde::de::Error::custom(
1131                        "response content was None",
1132                    )))
1133                }
1134            }
1135            Err(err) => Err(err),
1136        }
1137    }
1138
1139    /// Get all projects.
1140    pub async fn get_projects_with_http_info(
1141        &self,
1142    ) -> Result<
1143        datadog::ResponseContent<crate::datadogV2::model::ProjectsResponse>,
1144        datadog::Error<GetProjectsError>,
1145    > {
1146        let local_configuration = &self.config;
1147        let operation_id = "v2.get_projects";
1148
1149        let local_client = &self.client;
1150
1151        let local_uri_str = format!(
1152            "{}/api/v2/cases/projects",
1153            local_configuration.get_operation_host(operation_id)
1154        );
1155        let mut local_req_builder =
1156            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1157
1158        // build headers
1159        let mut headers = HeaderMap::new();
1160        headers.insert("Accept", HeaderValue::from_static("application/json"));
1161
1162        // build user agent
1163        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1164            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1165            Err(e) => {
1166                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1167                headers.insert(
1168                    reqwest::header::USER_AGENT,
1169                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1170                )
1171            }
1172        };
1173
1174        // build auth
1175        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1176            headers.insert(
1177                "DD-API-KEY",
1178                HeaderValue::from_str(local_key.key.as_str())
1179                    .expect("failed to parse DD-API-KEY header"),
1180            );
1181        };
1182        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1183            headers.insert(
1184                "DD-APPLICATION-KEY",
1185                HeaderValue::from_str(local_key.key.as_str())
1186                    .expect("failed to parse DD-APPLICATION-KEY header"),
1187            );
1188        };
1189
1190        local_req_builder = local_req_builder.headers(headers);
1191        let local_req = local_req_builder.build()?;
1192        log::debug!("request content: {:?}", local_req.body());
1193        let local_resp = local_client.execute(local_req).await?;
1194
1195        let local_status = local_resp.status();
1196        let local_content = local_resp.text().await?;
1197        log::debug!("response content: {}", local_content);
1198
1199        if !local_status.is_client_error() && !local_status.is_server_error() {
1200            match serde_json::from_str::<crate::datadogV2::model::ProjectsResponse>(&local_content)
1201            {
1202                Ok(e) => {
1203                    return Ok(datadog::ResponseContent {
1204                        status: local_status,
1205                        content: local_content,
1206                        entity: Some(e),
1207                    })
1208                }
1209                Err(e) => return Err(datadog::Error::Serde(e)),
1210            };
1211        } else {
1212            let local_entity: Option<GetProjectsError> = serde_json::from_str(&local_content).ok();
1213            let local_error = datadog::ResponseContent {
1214                status: local_status,
1215                content: local_content,
1216                entity: local_entity,
1217            };
1218            Err(datadog::Error::ResponseError(local_error))
1219        }
1220    }
1221
1222    /// Search cases.
1223    pub async fn search_cases(
1224        &self,
1225        params: SearchCasesOptionalParams,
1226    ) -> Result<crate::datadogV2::model::CasesResponse, datadog::Error<SearchCasesError>> {
1227        match self.search_cases_with_http_info(params).await {
1228            Ok(response_content) => {
1229                if let Some(e) = response_content.entity {
1230                    Ok(e)
1231                } else {
1232                    Err(datadog::Error::Serde(serde::de::Error::custom(
1233                        "response content was None",
1234                    )))
1235                }
1236            }
1237            Err(err) => Err(err),
1238        }
1239    }
1240
1241    pub fn search_cases_with_pagination(
1242        &self,
1243        mut params: SearchCasesOptionalParams,
1244    ) -> impl Stream<Item = Result<crate::datadogV2::model::Case, datadog::Error<SearchCasesError>>> + '_
1245    {
1246        try_stream! {
1247            let mut page_size: i64 = 10;
1248            if params.page_size.is_none() {
1249                params.page_size = Some(page_size);
1250            } else {
1251                page_size = params.page_size.unwrap().clone();
1252            }
1253            if params.page_number.is_none() {
1254                params.page_number = Some(0);
1255            }
1256            loop {
1257                let resp = self.search_cases(params.clone()).await?;
1258                let Some(data) = resp.data else { break };
1259
1260                let r = data;
1261                let count = r.len();
1262                for team in r {
1263                    yield team;
1264                }
1265
1266                if count < page_size as usize {
1267                    break;
1268                }
1269                params.page_number = Some(params.page_number.unwrap() + 1);
1270            }
1271        }
1272    }
1273
1274    /// Search cases.
1275    pub async fn search_cases_with_http_info(
1276        &self,
1277        params: SearchCasesOptionalParams,
1278    ) -> Result<
1279        datadog::ResponseContent<crate::datadogV2::model::CasesResponse>,
1280        datadog::Error<SearchCasesError>,
1281    > {
1282        let local_configuration = &self.config;
1283        let operation_id = "v2.search_cases";
1284
1285        // unbox and build optional parameters
1286        let page_size = params.page_size;
1287        let page_number = params.page_number;
1288        let sort_field = params.sort_field;
1289        let filter = params.filter;
1290        let sort_asc = params.sort_asc;
1291
1292        let local_client = &self.client;
1293
1294        let local_uri_str = format!(
1295            "{}/api/v2/cases",
1296            local_configuration.get_operation_host(operation_id)
1297        );
1298        let mut local_req_builder =
1299            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1300
1301        if let Some(ref local_query_param) = page_size {
1302            local_req_builder =
1303                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
1304        };
1305        if let Some(ref local_query_param) = page_number {
1306            local_req_builder =
1307                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
1308        };
1309        if let Some(ref local_query_param) = sort_field {
1310            local_req_builder =
1311                local_req_builder.query(&[("sort[field]", &local_query_param.to_string())]);
1312        };
1313        if let Some(ref local_query_param) = filter {
1314            local_req_builder =
1315                local_req_builder.query(&[("filter", &local_query_param.to_string())]);
1316        };
1317        if let Some(ref local_query_param) = sort_asc {
1318            local_req_builder =
1319                local_req_builder.query(&[("sort[asc]", &local_query_param.to_string())]);
1320        };
1321
1322        // build headers
1323        let mut headers = HeaderMap::new();
1324        headers.insert("Accept", HeaderValue::from_static("application/json"));
1325
1326        // build user agent
1327        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1328            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1329            Err(e) => {
1330                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1331                headers.insert(
1332                    reqwest::header::USER_AGENT,
1333                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1334                )
1335            }
1336        };
1337
1338        // build auth
1339        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1340            headers.insert(
1341                "DD-API-KEY",
1342                HeaderValue::from_str(local_key.key.as_str())
1343                    .expect("failed to parse DD-API-KEY header"),
1344            );
1345        };
1346        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1347            headers.insert(
1348                "DD-APPLICATION-KEY",
1349                HeaderValue::from_str(local_key.key.as_str())
1350                    .expect("failed to parse DD-APPLICATION-KEY header"),
1351            );
1352        };
1353
1354        local_req_builder = local_req_builder.headers(headers);
1355        let local_req = local_req_builder.build()?;
1356        log::debug!("request content: {:?}", local_req.body());
1357        let local_resp = local_client.execute(local_req).await?;
1358
1359        let local_status = local_resp.status();
1360        let local_content = local_resp.text().await?;
1361        log::debug!("response content: {}", local_content);
1362
1363        if !local_status.is_client_error() && !local_status.is_server_error() {
1364            match serde_json::from_str::<crate::datadogV2::model::CasesResponse>(&local_content) {
1365                Ok(e) => {
1366                    return Ok(datadog::ResponseContent {
1367                        status: local_status,
1368                        content: local_content,
1369                        entity: Some(e),
1370                    })
1371                }
1372                Err(e) => return Err(datadog::Error::Serde(e)),
1373            };
1374        } else {
1375            let local_entity: Option<SearchCasesError> = serde_json::from_str(&local_content).ok();
1376            let local_error = datadog::ResponseContent {
1377                status: local_status,
1378                content: local_content,
1379                entity: local_entity,
1380            };
1381            Err(datadog::Error::ResponseError(local_error))
1382        }
1383    }
1384
1385    /// Unarchive case
1386    pub async fn unarchive_case(
1387        &self,
1388        case_id: String,
1389        body: crate::datadogV2::model::CaseEmptyRequest,
1390    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<UnarchiveCaseError>> {
1391        match self.unarchive_case_with_http_info(case_id, body).await {
1392            Ok(response_content) => {
1393                if let Some(e) = response_content.entity {
1394                    Ok(e)
1395                } else {
1396                    Err(datadog::Error::Serde(serde::de::Error::custom(
1397                        "response content was None",
1398                    )))
1399                }
1400            }
1401            Err(err) => Err(err),
1402        }
1403    }
1404
1405    /// Unarchive case
1406    pub async fn unarchive_case_with_http_info(
1407        &self,
1408        case_id: String,
1409        body: crate::datadogV2::model::CaseEmptyRequest,
1410    ) -> Result<
1411        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
1412        datadog::Error<UnarchiveCaseError>,
1413    > {
1414        let local_configuration = &self.config;
1415        let operation_id = "v2.unarchive_case";
1416
1417        let local_client = &self.client;
1418
1419        let local_uri_str = format!(
1420            "{}/api/v2/cases/{case_id}/unarchive",
1421            local_configuration.get_operation_host(operation_id),
1422            case_id = datadog::urlencode(case_id)
1423        );
1424        let mut local_req_builder =
1425            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1426
1427        // build headers
1428        let mut headers = HeaderMap::new();
1429        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1430        headers.insert("Accept", HeaderValue::from_static("application/json"));
1431
1432        // build user agent
1433        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1434            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1435            Err(e) => {
1436                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1437                headers.insert(
1438                    reqwest::header::USER_AGENT,
1439                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1440                )
1441            }
1442        };
1443
1444        // build auth
1445        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1446            headers.insert(
1447                "DD-API-KEY",
1448                HeaderValue::from_str(local_key.key.as_str())
1449                    .expect("failed to parse DD-API-KEY header"),
1450            );
1451        };
1452        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1453            headers.insert(
1454                "DD-APPLICATION-KEY",
1455                HeaderValue::from_str(local_key.key.as_str())
1456                    .expect("failed to parse DD-APPLICATION-KEY header"),
1457            );
1458        };
1459
1460        // build body parameters
1461        let output = Vec::new();
1462        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1463        if body.serialize(&mut ser).is_ok() {
1464            if let Some(content_encoding) = headers.get("Content-Encoding") {
1465                match content_encoding.to_str().unwrap_or_default() {
1466                    "gzip" => {
1467                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1468                        let _ = enc.write_all(ser.into_inner().as_slice());
1469                        match enc.finish() {
1470                            Ok(buf) => {
1471                                local_req_builder = local_req_builder.body(buf);
1472                            }
1473                            Err(e) => return Err(datadog::Error::Io(e)),
1474                        }
1475                    }
1476                    "deflate" => {
1477                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1478                        let _ = enc.write_all(ser.into_inner().as_slice());
1479                        match enc.finish() {
1480                            Ok(buf) => {
1481                                local_req_builder = local_req_builder.body(buf);
1482                            }
1483                            Err(e) => return Err(datadog::Error::Io(e)),
1484                        }
1485                    }
1486                    "zstd1" => {
1487                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1488                        let _ = enc.write_all(ser.into_inner().as_slice());
1489                        match enc.finish() {
1490                            Ok(buf) => {
1491                                local_req_builder = local_req_builder.body(buf);
1492                            }
1493                            Err(e) => return Err(datadog::Error::Io(e)),
1494                        }
1495                    }
1496                    _ => {
1497                        local_req_builder = local_req_builder.body(ser.into_inner());
1498                    }
1499                }
1500            } else {
1501                local_req_builder = local_req_builder.body(ser.into_inner());
1502            }
1503        }
1504
1505        local_req_builder = local_req_builder.headers(headers);
1506        let local_req = local_req_builder.build()?;
1507        log::debug!("request content: {:?}", local_req.body());
1508        let local_resp = local_client.execute(local_req).await?;
1509
1510        let local_status = local_resp.status();
1511        let local_content = local_resp.text().await?;
1512        log::debug!("response content: {}", local_content);
1513
1514        if !local_status.is_client_error() && !local_status.is_server_error() {
1515            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
1516                Ok(e) => {
1517                    return Ok(datadog::ResponseContent {
1518                        status: local_status,
1519                        content: local_content,
1520                        entity: Some(e),
1521                    })
1522                }
1523                Err(e) => return Err(datadog::Error::Serde(e)),
1524            };
1525        } else {
1526            let local_entity: Option<UnarchiveCaseError> =
1527                serde_json::from_str(&local_content).ok();
1528            let local_error = datadog::ResponseContent {
1529                status: local_status,
1530                content: local_content,
1531                entity: local_entity,
1532            };
1533            Err(datadog::Error::ResponseError(local_error))
1534        }
1535    }
1536
1537    /// Unassign case
1538    pub async fn unassign_case(
1539        &self,
1540        case_id: String,
1541        body: crate::datadogV2::model::CaseEmptyRequest,
1542    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<UnassignCaseError>> {
1543        match self.unassign_case_with_http_info(case_id, body).await {
1544            Ok(response_content) => {
1545                if let Some(e) = response_content.entity {
1546                    Ok(e)
1547                } else {
1548                    Err(datadog::Error::Serde(serde::de::Error::custom(
1549                        "response content was None",
1550                    )))
1551                }
1552            }
1553            Err(err) => Err(err),
1554        }
1555    }
1556
1557    /// Unassign case
1558    pub async fn unassign_case_with_http_info(
1559        &self,
1560        case_id: String,
1561        body: crate::datadogV2::model::CaseEmptyRequest,
1562    ) -> Result<
1563        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
1564        datadog::Error<UnassignCaseError>,
1565    > {
1566        let local_configuration = &self.config;
1567        let operation_id = "v2.unassign_case";
1568
1569        let local_client = &self.client;
1570
1571        let local_uri_str = format!(
1572            "{}/api/v2/cases/{case_id}/unassign",
1573            local_configuration.get_operation_host(operation_id),
1574            case_id = datadog::urlencode(case_id)
1575        );
1576        let mut local_req_builder =
1577            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1578
1579        // build headers
1580        let mut headers = HeaderMap::new();
1581        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1582        headers.insert("Accept", HeaderValue::from_static("application/json"));
1583
1584        // build user agent
1585        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1586            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1587            Err(e) => {
1588                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1589                headers.insert(
1590                    reqwest::header::USER_AGENT,
1591                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1592                )
1593            }
1594        };
1595
1596        // build auth
1597        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1598            headers.insert(
1599                "DD-API-KEY",
1600                HeaderValue::from_str(local_key.key.as_str())
1601                    .expect("failed to parse DD-API-KEY header"),
1602            );
1603        };
1604        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1605            headers.insert(
1606                "DD-APPLICATION-KEY",
1607                HeaderValue::from_str(local_key.key.as_str())
1608                    .expect("failed to parse DD-APPLICATION-KEY header"),
1609            );
1610        };
1611
1612        // build body parameters
1613        let output = Vec::new();
1614        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1615        if body.serialize(&mut ser).is_ok() {
1616            if let Some(content_encoding) = headers.get("Content-Encoding") {
1617                match content_encoding.to_str().unwrap_or_default() {
1618                    "gzip" => {
1619                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1620                        let _ = enc.write_all(ser.into_inner().as_slice());
1621                        match enc.finish() {
1622                            Ok(buf) => {
1623                                local_req_builder = local_req_builder.body(buf);
1624                            }
1625                            Err(e) => return Err(datadog::Error::Io(e)),
1626                        }
1627                    }
1628                    "deflate" => {
1629                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1630                        let _ = enc.write_all(ser.into_inner().as_slice());
1631                        match enc.finish() {
1632                            Ok(buf) => {
1633                                local_req_builder = local_req_builder.body(buf);
1634                            }
1635                            Err(e) => return Err(datadog::Error::Io(e)),
1636                        }
1637                    }
1638                    "zstd1" => {
1639                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1640                        let _ = enc.write_all(ser.into_inner().as_slice());
1641                        match enc.finish() {
1642                            Ok(buf) => {
1643                                local_req_builder = local_req_builder.body(buf);
1644                            }
1645                            Err(e) => return Err(datadog::Error::Io(e)),
1646                        }
1647                    }
1648                    _ => {
1649                        local_req_builder = local_req_builder.body(ser.into_inner());
1650                    }
1651                }
1652            } else {
1653                local_req_builder = local_req_builder.body(ser.into_inner());
1654            }
1655        }
1656
1657        local_req_builder = local_req_builder.headers(headers);
1658        let local_req = local_req_builder.build()?;
1659        log::debug!("request content: {:?}", local_req.body());
1660        let local_resp = local_client.execute(local_req).await?;
1661
1662        let local_status = local_resp.status();
1663        let local_content = local_resp.text().await?;
1664        log::debug!("response content: {}", local_content);
1665
1666        if !local_status.is_client_error() && !local_status.is_server_error() {
1667            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
1668                Ok(e) => {
1669                    return Ok(datadog::ResponseContent {
1670                        status: local_status,
1671                        content: local_content,
1672                        entity: Some(e),
1673                    })
1674                }
1675                Err(e) => return Err(datadog::Error::Serde(e)),
1676            };
1677        } else {
1678            let local_entity: Option<UnassignCaseError> = serde_json::from_str(&local_content).ok();
1679            let local_error = datadog::ResponseContent {
1680                status: local_status,
1681                content: local_content,
1682                entity: local_entity,
1683            };
1684            Err(datadog::Error::ResponseError(local_error))
1685        }
1686    }
1687
1688    /// Update case priority
1689    pub async fn update_priority(
1690        &self,
1691        case_id: String,
1692        body: crate::datadogV2::model::CaseUpdatePriorityRequest,
1693    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<UpdatePriorityError>> {
1694        match self.update_priority_with_http_info(case_id, body).await {
1695            Ok(response_content) => {
1696                if let Some(e) = response_content.entity {
1697                    Ok(e)
1698                } else {
1699                    Err(datadog::Error::Serde(serde::de::Error::custom(
1700                        "response content was None",
1701                    )))
1702                }
1703            }
1704            Err(err) => Err(err),
1705        }
1706    }
1707
1708    /// Update case priority
1709    pub async fn update_priority_with_http_info(
1710        &self,
1711        case_id: String,
1712        body: crate::datadogV2::model::CaseUpdatePriorityRequest,
1713    ) -> Result<
1714        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
1715        datadog::Error<UpdatePriorityError>,
1716    > {
1717        let local_configuration = &self.config;
1718        let operation_id = "v2.update_priority";
1719
1720        let local_client = &self.client;
1721
1722        let local_uri_str = format!(
1723            "{}/api/v2/cases/{case_id}/priority",
1724            local_configuration.get_operation_host(operation_id),
1725            case_id = datadog::urlencode(case_id)
1726        );
1727        let mut local_req_builder =
1728            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1729
1730        // build headers
1731        let mut headers = HeaderMap::new();
1732        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1733        headers.insert("Accept", HeaderValue::from_static("application/json"));
1734
1735        // build user agent
1736        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1737            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1738            Err(e) => {
1739                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1740                headers.insert(
1741                    reqwest::header::USER_AGENT,
1742                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1743                )
1744            }
1745        };
1746
1747        // build auth
1748        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1749            headers.insert(
1750                "DD-API-KEY",
1751                HeaderValue::from_str(local_key.key.as_str())
1752                    .expect("failed to parse DD-API-KEY header"),
1753            );
1754        };
1755        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1756            headers.insert(
1757                "DD-APPLICATION-KEY",
1758                HeaderValue::from_str(local_key.key.as_str())
1759                    .expect("failed to parse DD-APPLICATION-KEY header"),
1760            );
1761        };
1762
1763        // build body parameters
1764        let output = Vec::new();
1765        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1766        if body.serialize(&mut ser).is_ok() {
1767            if let Some(content_encoding) = headers.get("Content-Encoding") {
1768                match content_encoding.to_str().unwrap_or_default() {
1769                    "gzip" => {
1770                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1771                        let _ = enc.write_all(ser.into_inner().as_slice());
1772                        match enc.finish() {
1773                            Ok(buf) => {
1774                                local_req_builder = local_req_builder.body(buf);
1775                            }
1776                            Err(e) => return Err(datadog::Error::Io(e)),
1777                        }
1778                    }
1779                    "deflate" => {
1780                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1781                        let _ = enc.write_all(ser.into_inner().as_slice());
1782                        match enc.finish() {
1783                            Ok(buf) => {
1784                                local_req_builder = local_req_builder.body(buf);
1785                            }
1786                            Err(e) => return Err(datadog::Error::Io(e)),
1787                        }
1788                    }
1789                    "zstd1" => {
1790                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1791                        let _ = enc.write_all(ser.into_inner().as_slice());
1792                        match enc.finish() {
1793                            Ok(buf) => {
1794                                local_req_builder = local_req_builder.body(buf);
1795                            }
1796                            Err(e) => return Err(datadog::Error::Io(e)),
1797                        }
1798                    }
1799                    _ => {
1800                        local_req_builder = local_req_builder.body(ser.into_inner());
1801                    }
1802                }
1803            } else {
1804                local_req_builder = local_req_builder.body(ser.into_inner());
1805            }
1806        }
1807
1808        local_req_builder = local_req_builder.headers(headers);
1809        let local_req = local_req_builder.build()?;
1810        log::debug!("request content: {:?}", local_req.body());
1811        let local_resp = local_client.execute(local_req).await?;
1812
1813        let local_status = local_resp.status();
1814        let local_content = local_resp.text().await?;
1815        log::debug!("response content: {}", local_content);
1816
1817        if !local_status.is_client_error() && !local_status.is_server_error() {
1818            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
1819                Ok(e) => {
1820                    return Ok(datadog::ResponseContent {
1821                        status: local_status,
1822                        content: local_content,
1823                        entity: Some(e),
1824                    })
1825                }
1826                Err(e) => return Err(datadog::Error::Serde(e)),
1827            };
1828        } else {
1829            let local_entity: Option<UpdatePriorityError> =
1830                serde_json::from_str(&local_content).ok();
1831            let local_error = datadog::ResponseContent {
1832                status: local_status,
1833                content: local_content,
1834                entity: local_entity,
1835            };
1836            Err(datadog::Error::ResponseError(local_error))
1837        }
1838    }
1839
1840    /// Update case status
1841    pub async fn update_status(
1842        &self,
1843        case_id: String,
1844        body: crate::datadogV2::model::CaseUpdateStatusRequest,
1845    ) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<UpdateStatusError>> {
1846        match self.update_status_with_http_info(case_id, body).await {
1847            Ok(response_content) => {
1848                if let Some(e) = response_content.entity {
1849                    Ok(e)
1850                } else {
1851                    Err(datadog::Error::Serde(serde::de::Error::custom(
1852                        "response content was None",
1853                    )))
1854                }
1855            }
1856            Err(err) => Err(err),
1857        }
1858    }
1859
1860    /// Update case status
1861    pub async fn update_status_with_http_info(
1862        &self,
1863        case_id: String,
1864        body: crate::datadogV2::model::CaseUpdateStatusRequest,
1865    ) -> Result<
1866        datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
1867        datadog::Error<UpdateStatusError>,
1868    > {
1869        let local_configuration = &self.config;
1870        let operation_id = "v2.update_status";
1871
1872        let local_client = &self.client;
1873
1874        let local_uri_str = format!(
1875            "{}/api/v2/cases/{case_id}/status",
1876            local_configuration.get_operation_host(operation_id),
1877            case_id = datadog::urlencode(case_id)
1878        );
1879        let mut local_req_builder =
1880            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1881
1882        // build headers
1883        let mut headers = HeaderMap::new();
1884        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1885        headers.insert("Accept", HeaderValue::from_static("application/json"));
1886
1887        // build user agent
1888        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1889            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1890            Err(e) => {
1891                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1892                headers.insert(
1893                    reqwest::header::USER_AGENT,
1894                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1895                )
1896            }
1897        };
1898
1899        // build auth
1900        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1901            headers.insert(
1902                "DD-API-KEY",
1903                HeaderValue::from_str(local_key.key.as_str())
1904                    .expect("failed to parse DD-API-KEY header"),
1905            );
1906        };
1907        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1908            headers.insert(
1909                "DD-APPLICATION-KEY",
1910                HeaderValue::from_str(local_key.key.as_str())
1911                    .expect("failed to parse DD-APPLICATION-KEY header"),
1912            );
1913        };
1914
1915        // build body parameters
1916        let output = Vec::new();
1917        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1918        if body.serialize(&mut ser).is_ok() {
1919            if let Some(content_encoding) = headers.get("Content-Encoding") {
1920                match content_encoding.to_str().unwrap_or_default() {
1921                    "gzip" => {
1922                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1923                        let _ = enc.write_all(ser.into_inner().as_slice());
1924                        match enc.finish() {
1925                            Ok(buf) => {
1926                                local_req_builder = local_req_builder.body(buf);
1927                            }
1928                            Err(e) => return Err(datadog::Error::Io(e)),
1929                        }
1930                    }
1931                    "deflate" => {
1932                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1933                        let _ = enc.write_all(ser.into_inner().as_slice());
1934                        match enc.finish() {
1935                            Ok(buf) => {
1936                                local_req_builder = local_req_builder.body(buf);
1937                            }
1938                            Err(e) => return Err(datadog::Error::Io(e)),
1939                        }
1940                    }
1941                    "zstd1" => {
1942                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1943                        let _ = enc.write_all(ser.into_inner().as_slice());
1944                        match enc.finish() {
1945                            Ok(buf) => {
1946                                local_req_builder = local_req_builder.body(buf);
1947                            }
1948                            Err(e) => return Err(datadog::Error::Io(e)),
1949                        }
1950                    }
1951                    _ => {
1952                        local_req_builder = local_req_builder.body(ser.into_inner());
1953                    }
1954                }
1955            } else {
1956                local_req_builder = local_req_builder.body(ser.into_inner());
1957            }
1958        }
1959
1960        local_req_builder = local_req_builder.headers(headers);
1961        let local_req = local_req_builder.build()?;
1962        log::debug!("request content: {:?}", local_req.body());
1963        let local_resp = local_client.execute(local_req).await?;
1964
1965        let local_status = local_resp.status();
1966        let local_content = local_resp.text().await?;
1967        log::debug!("response content: {}", local_content);
1968
1969        if !local_status.is_client_error() && !local_status.is_server_error() {
1970            match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
1971                Ok(e) => {
1972                    return Ok(datadog::ResponseContent {
1973                        status: local_status,
1974                        content: local_content,
1975                        entity: Some(e),
1976                    })
1977                }
1978                Err(e) => return Err(datadog::Error::Serde(e)),
1979            };
1980        } else {
1981            let local_entity: Option<UpdateStatusError> = serde_json::from_str(&local_content).ok();
1982            let local_error = datadog::ResponseContent {
1983                status: local_status,
1984                content: local_content,
1985                entity: local_entity,
1986            };
1987            Err(datadog::Error::ResponseError(local_error))
1988        }
1989    }
1990}