datadog_api_client/datadogV2/api/
api_incidents.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 log::warn;
12use reqwest::header::{HeaderMap, HeaderValue};
13use serde::{Deserialize, Serialize};
14use std::io::Write;
15
16/// CreateIncidentImpactOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_impact`]
17#[non_exhaustive]
18#[derive(Clone, Default, Debug)]
19pub struct CreateIncidentImpactOptionalParams {
20    /// Specifies which related resources should be included in the response.
21    pub include: Option<Vec<crate::datadogV2::model::IncidentImpactRelatedObject>>,
22}
23
24impl CreateIncidentImpactOptionalParams {
25    /// Specifies which related resources should be included in the response.
26    pub fn include(
27        mut self,
28        value: Vec<crate::datadogV2::model::IncidentImpactRelatedObject>,
29    ) -> Self {
30        self.include = Some(value);
31        self
32    }
33}
34
35/// DeleteIncidentNotificationRuleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::delete_incident_notification_rule`]
36#[non_exhaustive]
37#[derive(Clone, Default, Debug)]
38pub struct DeleteIncidentNotificationRuleOptionalParams {
39    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
40    pub include: Option<String>,
41}
42
43impl DeleteIncidentNotificationRuleOptionalParams {
44    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
45    pub fn include(mut self, value: String) -> Self {
46        self.include = Some(value);
47        self
48    }
49}
50
51/// DeleteIncidentNotificationTemplateOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::delete_incident_notification_template`]
52#[non_exhaustive]
53#[derive(Clone, Default, Debug)]
54pub struct DeleteIncidentNotificationTemplateOptionalParams {
55    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
56    pub include: Option<String>,
57}
58
59impl DeleteIncidentNotificationTemplateOptionalParams {
60    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
61    pub fn include(mut self, value: String) -> Self {
62        self.include = Some(value);
63        self
64    }
65}
66
67/// GetIncidentOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident`]
68#[non_exhaustive]
69#[derive(Clone, Default, Debug)]
70pub struct GetIncidentOptionalParams {
71    /// Specifies which types of related objects should be included in the response.
72    pub include: Option<Vec<crate::datadogV2::model::IncidentRelatedObject>>,
73}
74
75impl GetIncidentOptionalParams {
76    /// Specifies which types of related objects should be included in the response.
77    pub fn include(mut self, value: Vec<crate::datadogV2::model::IncidentRelatedObject>) -> Self {
78        self.include = Some(value);
79        self
80    }
81}
82
83/// GetIncidentNotificationRuleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident_notification_rule`]
84#[non_exhaustive]
85#[derive(Clone, Default, Debug)]
86pub struct GetIncidentNotificationRuleOptionalParams {
87    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
88    pub include: Option<String>,
89}
90
91impl GetIncidentNotificationRuleOptionalParams {
92    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
93    pub fn include(mut self, value: String) -> Self {
94        self.include = Some(value);
95        self
96    }
97}
98
99/// GetIncidentNotificationTemplateOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident_notification_template`]
100#[non_exhaustive]
101#[derive(Clone, Default, Debug)]
102pub struct GetIncidentNotificationTemplateOptionalParams {
103    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
104    pub include: Option<String>,
105}
106
107impl GetIncidentNotificationTemplateOptionalParams {
108    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
109    pub fn include(mut self, value: String) -> Self {
110        self.include = Some(value);
111        self
112    }
113}
114
115/// ListIncidentAttachmentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_attachments`]
116#[non_exhaustive]
117#[derive(Clone, Default, Debug)]
118pub struct ListIncidentAttachmentsOptionalParams {
119    /// Specifies which types of related objects are included in the response.
120    pub include: Option<Vec<crate::datadogV2::model::IncidentAttachmentRelatedObject>>,
121    /// Specifies which types of attachments are included in the response.
122    pub filter_attachment_type:
123        Option<Vec<crate::datadogV2::model::IncidentAttachmentAttachmentType>>,
124}
125
126impl ListIncidentAttachmentsOptionalParams {
127    /// Specifies which types of related objects are included in the response.
128    pub fn include(
129        mut self,
130        value: Vec<crate::datadogV2::model::IncidentAttachmentRelatedObject>,
131    ) -> Self {
132        self.include = Some(value);
133        self
134    }
135    /// Specifies which types of attachments are included in the response.
136    pub fn filter_attachment_type(
137        mut self,
138        value: Vec<crate::datadogV2::model::IncidentAttachmentAttachmentType>,
139    ) -> Self {
140        self.filter_attachment_type = Some(value);
141        self
142    }
143}
144
145/// ListIncidentImpactsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_impacts`]
146#[non_exhaustive]
147#[derive(Clone, Default, Debug)]
148pub struct ListIncidentImpactsOptionalParams {
149    /// Specifies which related resources should be included in the response.
150    pub include: Option<Vec<crate::datadogV2::model::IncidentImpactRelatedObject>>,
151}
152
153impl ListIncidentImpactsOptionalParams {
154    /// Specifies which related resources should be included in the response.
155    pub fn include(
156        mut self,
157        value: Vec<crate::datadogV2::model::IncidentImpactRelatedObject>,
158    ) -> Self {
159        self.include = Some(value);
160        self
161    }
162}
163
164/// ListIncidentNotificationRulesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_notification_rules`]
165#[non_exhaustive]
166#[derive(Clone, Default, Debug)]
167pub struct ListIncidentNotificationRulesOptionalParams {
168    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
169    pub include: Option<String>,
170}
171
172impl ListIncidentNotificationRulesOptionalParams {
173    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
174    pub fn include(mut self, value: String) -> Self {
175        self.include = Some(value);
176        self
177    }
178}
179
180/// ListIncidentNotificationTemplatesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_notification_templates`]
181#[non_exhaustive]
182#[derive(Clone, Default, Debug)]
183pub struct ListIncidentNotificationTemplatesOptionalParams {
184    /// Optional incident type ID filter.
185    pub filter_incident_type: Option<uuid::Uuid>,
186    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
187    pub include: Option<String>,
188}
189
190impl ListIncidentNotificationTemplatesOptionalParams {
191    /// Optional incident type ID filter.
192    pub fn filter_incident_type(mut self, value: uuid::Uuid) -> Self {
193        self.filter_incident_type = Some(value);
194        self
195    }
196    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
197    pub fn include(mut self, value: String) -> Self {
198        self.include = Some(value);
199        self
200    }
201}
202
203/// ListIncidentTypesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_types`]
204#[non_exhaustive]
205#[derive(Clone, Default, Debug)]
206pub struct ListIncidentTypesOptionalParams {
207    /// Include deleted incident types in the response.
208    pub include_deleted: Option<bool>,
209}
210
211impl ListIncidentTypesOptionalParams {
212    /// Include deleted incident types in the response.
213    pub fn include_deleted(mut self, value: bool) -> Self {
214        self.include_deleted = Some(value);
215        self
216    }
217}
218
219/// ListIncidentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incidents`]
220#[non_exhaustive]
221#[derive(Clone, Default, Debug)]
222pub struct ListIncidentsOptionalParams {
223    /// Specifies which types of related objects should be included in the response.
224    pub include: Option<Vec<crate::datadogV2::model::IncidentRelatedObject>>,
225    /// Size for a given page. The maximum allowed value is 100.
226    pub page_size: Option<i64>,
227    /// Specific offset to use as the beginning of the returned page.
228    pub page_offset: Option<i64>,
229}
230
231impl ListIncidentsOptionalParams {
232    /// Specifies which types of related objects should be included in the response.
233    pub fn include(mut self, value: Vec<crate::datadogV2::model::IncidentRelatedObject>) -> Self {
234        self.include = Some(value);
235        self
236    }
237    /// Size for a given page. The maximum allowed value is 100.
238    pub fn page_size(mut self, value: i64) -> Self {
239        self.page_size = Some(value);
240        self
241    }
242    /// Specific offset to use as the beginning of the returned page.
243    pub fn page_offset(mut self, value: i64) -> Self {
244        self.page_offset = Some(value);
245        self
246    }
247}
248
249/// SearchIncidentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::search_incidents`]
250#[non_exhaustive]
251#[derive(Clone, Default, Debug)]
252pub struct SearchIncidentsOptionalParams {
253    /// Specifies which types of related objects should be included in the response.
254    pub include: Option<crate::datadogV2::model::IncidentRelatedObject>,
255    /// Specifies the order of returned incidents.
256    pub sort: Option<crate::datadogV2::model::IncidentSearchSortOrder>,
257    /// Size for a given page. The maximum allowed value is 100.
258    pub page_size: Option<i64>,
259    /// Specific offset to use as the beginning of the returned page.
260    pub page_offset: Option<i64>,
261}
262
263impl SearchIncidentsOptionalParams {
264    /// Specifies which types of related objects should be included in the response.
265    pub fn include(mut self, value: crate::datadogV2::model::IncidentRelatedObject) -> Self {
266        self.include = Some(value);
267        self
268    }
269    /// Specifies the order of returned incidents.
270    pub fn sort(mut self, value: crate::datadogV2::model::IncidentSearchSortOrder) -> Self {
271        self.sort = Some(value);
272        self
273    }
274    /// Size for a given page. The maximum allowed value is 100.
275    pub fn page_size(mut self, value: i64) -> Self {
276        self.page_size = Some(value);
277        self
278    }
279    /// Specific offset to use as the beginning of the returned page.
280    pub fn page_offset(mut self, value: i64) -> Self {
281        self.page_offset = Some(value);
282        self
283    }
284}
285
286/// UpdateIncidentOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident`]
287#[non_exhaustive]
288#[derive(Clone, Default, Debug)]
289pub struct UpdateIncidentOptionalParams {
290    /// Specifies which types of related objects should be included in the response.
291    pub include: Option<Vec<crate::datadogV2::model::IncidentRelatedObject>>,
292}
293
294impl UpdateIncidentOptionalParams {
295    /// Specifies which types of related objects should be included in the response.
296    pub fn include(mut self, value: Vec<crate::datadogV2::model::IncidentRelatedObject>) -> Self {
297        self.include = Some(value);
298        self
299    }
300}
301
302/// UpdateIncidentAttachmentsOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_attachments`]
303#[non_exhaustive]
304#[derive(Clone, Default, Debug)]
305pub struct UpdateIncidentAttachmentsOptionalParams {
306    /// Specifies which types of related objects are included in the response.
307    pub include: Option<Vec<crate::datadogV2::model::IncidentAttachmentRelatedObject>>,
308}
309
310impl UpdateIncidentAttachmentsOptionalParams {
311    /// Specifies which types of related objects are included in the response.
312    pub fn include(
313        mut self,
314        value: Vec<crate::datadogV2::model::IncidentAttachmentRelatedObject>,
315    ) -> Self {
316        self.include = Some(value);
317        self
318    }
319}
320
321/// UpdateIncidentNotificationRuleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_notification_rule`]
322#[non_exhaustive]
323#[derive(Clone, Default, Debug)]
324pub struct UpdateIncidentNotificationRuleOptionalParams {
325    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
326    pub include: Option<String>,
327}
328
329impl UpdateIncidentNotificationRuleOptionalParams {
330    /// Comma-separated list of resources to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`, `notification_template`
331    pub fn include(mut self, value: String) -> Self {
332        self.include = Some(value);
333        self
334    }
335}
336
337/// UpdateIncidentNotificationTemplateOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_notification_template`]
338#[non_exhaustive]
339#[derive(Clone, Default, Debug)]
340pub struct UpdateIncidentNotificationTemplateOptionalParams {
341    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
342    pub include: Option<String>,
343}
344
345impl UpdateIncidentNotificationTemplateOptionalParams {
346    /// Comma-separated list of relationships to include. Supported values: `created_by_user`, `last_modified_by_user`, `incident_type`
347    pub fn include(mut self, value: String) -> Self {
348        self.include = Some(value);
349        self
350    }
351}
352
353/// CreateIncidentError is a struct for typed errors of method [`IncidentsAPI::create_incident`]
354#[derive(Debug, Clone, Serialize, Deserialize)]
355#[serde(untagged)]
356pub enum CreateIncidentError {
357    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
358    UnknownValue(serde_json::Value),
359}
360
361/// CreateIncidentImpactError is a struct for typed errors of method [`IncidentsAPI::create_incident_impact`]
362#[derive(Debug, Clone, Serialize, Deserialize)]
363#[serde(untagged)]
364pub enum CreateIncidentImpactError {
365    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
366    UnknownValue(serde_json::Value),
367}
368
369/// CreateIncidentIntegrationError is a struct for typed errors of method [`IncidentsAPI::create_incident_integration`]
370#[derive(Debug, Clone, Serialize, Deserialize)]
371#[serde(untagged)]
372pub enum CreateIncidentIntegrationError {
373    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
374    UnknownValue(serde_json::Value),
375}
376
377/// CreateIncidentNotificationRuleError is a struct for typed errors of method [`IncidentsAPI::create_incident_notification_rule`]
378#[derive(Debug, Clone, Serialize, Deserialize)]
379#[serde(untagged)]
380pub enum CreateIncidentNotificationRuleError {
381    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
382    UnknownValue(serde_json::Value),
383}
384
385/// CreateIncidentNotificationTemplateError is a struct for typed errors of method [`IncidentsAPI::create_incident_notification_template`]
386#[derive(Debug, Clone, Serialize, Deserialize)]
387#[serde(untagged)]
388pub enum CreateIncidentNotificationTemplateError {
389    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
390    UnknownValue(serde_json::Value),
391}
392
393/// CreateIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::create_incident_todo`]
394#[derive(Debug, Clone, Serialize, Deserialize)]
395#[serde(untagged)]
396pub enum CreateIncidentTodoError {
397    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
398    UnknownValue(serde_json::Value),
399}
400
401/// CreateIncidentTypeError is a struct for typed errors of method [`IncidentsAPI::create_incident_type`]
402#[derive(Debug, Clone, Serialize, Deserialize)]
403#[serde(untagged)]
404pub enum CreateIncidentTypeError {
405    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
406    UnknownValue(serde_json::Value),
407}
408
409/// DeleteIncidentError is a struct for typed errors of method [`IncidentsAPI::delete_incident`]
410#[derive(Debug, Clone, Serialize, Deserialize)]
411#[serde(untagged)]
412pub enum DeleteIncidentError {
413    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
414    UnknownValue(serde_json::Value),
415}
416
417/// DeleteIncidentImpactError is a struct for typed errors of method [`IncidentsAPI::delete_incident_impact`]
418#[derive(Debug, Clone, Serialize, Deserialize)]
419#[serde(untagged)]
420pub enum DeleteIncidentImpactError {
421    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
422    UnknownValue(serde_json::Value),
423}
424
425/// DeleteIncidentIntegrationError is a struct for typed errors of method [`IncidentsAPI::delete_incident_integration`]
426#[derive(Debug, Clone, Serialize, Deserialize)]
427#[serde(untagged)]
428pub enum DeleteIncidentIntegrationError {
429    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
430    UnknownValue(serde_json::Value),
431}
432
433/// DeleteIncidentNotificationRuleError is a struct for typed errors of method [`IncidentsAPI::delete_incident_notification_rule`]
434#[derive(Debug, Clone, Serialize, Deserialize)]
435#[serde(untagged)]
436pub enum DeleteIncidentNotificationRuleError {
437    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
438    UnknownValue(serde_json::Value),
439}
440
441/// DeleteIncidentNotificationTemplateError is a struct for typed errors of method [`IncidentsAPI::delete_incident_notification_template`]
442#[derive(Debug, Clone, Serialize, Deserialize)]
443#[serde(untagged)]
444pub enum DeleteIncidentNotificationTemplateError {
445    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
446    UnknownValue(serde_json::Value),
447}
448
449/// DeleteIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::delete_incident_todo`]
450#[derive(Debug, Clone, Serialize, Deserialize)]
451#[serde(untagged)]
452pub enum DeleteIncidentTodoError {
453    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
454    UnknownValue(serde_json::Value),
455}
456
457/// DeleteIncidentTypeError is a struct for typed errors of method [`IncidentsAPI::delete_incident_type`]
458#[derive(Debug, Clone, Serialize, Deserialize)]
459#[serde(untagged)]
460pub enum DeleteIncidentTypeError {
461    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
462    UnknownValue(serde_json::Value),
463}
464
465/// GetIncidentError is a struct for typed errors of method [`IncidentsAPI::get_incident`]
466#[derive(Debug, Clone, Serialize, Deserialize)]
467#[serde(untagged)]
468pub enum GetIncidentError {
469    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
470    UnknownValue(serde_json::Value),
471}
472
473/// GetIncidentIntegrationError is a struct for typed errors of method [`IncidentsAPI::get_incident_integration`]
474#[derive(Debug, Clone, Serialize, Deserialize)]
475#[serde(untagged)]
476pub enum GetIncidentIntegrationError {
477    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
478    UnknownValue(serde_json::Value),
479}
480
481/// GetIncidentNotificationRuleError is a struct for typed errors of method [`IncidentsAPI::get_incident_notification_rule`]
482#[derive(Debug, Clone, Serialize, Deserialize)]
483#[serde(untagged)]
484pub enum GetIncidentNotificationRuleError {
485    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
486    UnknownValue(serde_json::Value),
487}
488
489/// GetIncidentNotificationTemplateError is a struct for typed errors of method [`IncidentsAPI::get_incident_notification_template`]
490#[derive(Debug, Clone, Serialize, Deserialize)]
491#[serde(untagged)]
492pub enum GetIncidentNotificationTemplateError {
493    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
494    UnknownValue(serde_json::Value),
495}
496
497/// GetIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::get_incident_todo`]
498#[derive(Debug, Clone, Serialize, Deserialize)]
499#[serde(untagged)]
500pub enum GetIncidentTodoError {
501    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
502    UnknownValue(serde_json::Value),
503}
504
505/// GetIncidentTypeError is a struct for typed errors of method [`IncidentsAPI::get_incident_type`]
506#[derive(Debug, Clone, Serialize, Deserialize)]
507#[serde(untagged)]
508pub enum GetIncidentTypeError {
509    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
510    UnknownValue(serde_json::Value),
511}
512
513/// ListIncidentAttachmentsError is a struct for typed errors of method [`IncidentsAPI::list_incident_attachments`]
514#[derive(Debug, Clone, Serialize, Deserialize)]
515#[serde(untagged)]
516pub enum ListIncidentAttachmentsError {
517    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
518    UnknownValue(serde_json::Value),
519}
520
521/// ListIncidentImpactsError is a struct for typed errors of method [`IncidentsAPI::list_incident_impacts`]
522#[derive(Debug, Clone, Serialize, Deserialize)]
523#[serde(untagged)]
524pub enum ListIncidentImpactsError {
525    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
526    UnknownValue(serde_json::Value),
527}
528
529/// ListIncidentIntegrationsError is a struct for typed errors of method [`IncidentsAPI::list_incident_integrations`]
530#[derive(Debug, Clone, Serialize, Deserialize)]
531#[serde(untagged)]
532pub enum ListIncidentIntegrationsError {
533    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
534    UnknownValue(serde_json::Value),
535}
536
537/// ListIncidentNotificationRulesError is a struct for typed errors of method [`IncidentsAPI::list_incident_notification_rules`]
538#[derive(Debug, Clone, Serialize, Deserialize)]
539#[serde(untagged)]
540pub enum ListIncidentNotificationRulesError {
541    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
542    UnknownValue(serde_json::Value),
543}
544
545/// ListIncidentNotificationTemplatesError is a struct for typed errors of method [`IncidentsAPI::list_incident_notification_templates`]
546#[derive(Debug, Clone, Serialize, Deserialize)]
547#[serde(untagged)]
548pub enum ListIncidentNotificationTemplatesError {
549    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
550    UnknownValue(serde_json::Value),
551}
552
553/// ListIncidentTodosError is a struct for typed errors of method [`IncidentsAPI::list_incident_todos`]
554#[derive(Debug, Clone, Serialize, Deserialize)]
555#[serde(untagged)]
556pub enum ListIncidentTodosError {
557    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
558    UnknownValue(serde_json::Value),
559}
560
561/// ListIncidentTypesError is a struct for typed errors of method [`IncidentsAPI::list_incident_types`]
562#[derive(Debug, Clone, Serialize, Deserialize)]
563#[serde(untagged)]
564pub enum ListIncidentTypesError {
565    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
566    UnknownValue(serde_json::Value),
567}
568
569/// ListIncidentsError is a struct for typed errors of method [`IncidentsAPI::list_incidents`]
570#[derive(Debug, Clone, Serialize, Deserialize)]
571#[serde(untagged)]
572pub enum ListIncidentsError {
573    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
574    UnknownValue(serde_json::Value),
575}
576
577/// SearchIncidentsError is a struct for typed errors of method [`IncidentsAPI::search_incidents`]
578#[derive(Debug, Clone, Serialize, Deserialize)]
579#[serde(untagged)]
580pub enum SearchIncidentsError {
581    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
582    UnknownValue(serde_json::Value),
583}
584
585/// UpdateIncidentError is a struct for typed errors of method [`IncidentsAPI::update_incident`]
586#[derive(Debug, Clone, Serialize, Deserialize)]
587#[serde(untagged)]
588pub enum UpdateIncidentError {
589    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
590    UnknownValue(serde_json::Value),
591}
592
593/// UpdateIncidentAttachmentsError is a struct for typed errors of method [`IncidentsAPI::update_incident_attachments`]
594#[derive(Debug, Clone, Serialize, Deserialize)]
595#[serde(untagged)]
596pub enum UpdateIncidentAttachmentsError {
597    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
598    UnknownValue(serde_json::Value),
599}
600
601/// UpdateIncidentIntegrationError is a struct for typed errors of method [`IncidentsAPI::update_incident_integration`]
602#[derive(Debug, Clone, Serialize, Deserialize)]
603#[serde(untagged)]
604pub enum UpdateIncidentIntegrationError {
605    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
606    UnknownValue(serde_json::Value),
607}
608
609/// UpdateIncidentNotificationRuleError is a struct for typed errors of method [`IncidentsAPI::update_incident_notification_rule`]
610#[derive(Debug, Clone, Serialize, Deserialize)]
611#[serde(untagged)]
612pub enum UpdateIncidentNotificationRuleError {
613    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
614    UnknownValue(serde_json::Value),
615}
616
617/// UpdateIncidentNotificationTemplateError is a struct for typed errors of method [`IncidentsAPI::update_incident_notification_template`]
618#[derive(Debug, Clone, Serialize, Deserialize)]
619#[serde(untagged)]
620pub enum UpdateIncidentNotificationTemplateError {
621    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
622    UnknownValue(serde_json::Value),
623}
624
625/// UpdateIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::update_incident_todo`]
626#[derive(Debug, Clone, Serialize, Deserialize)]
627#[serde(untagged)]
628pub enum UpdateIncidentTodoError {
629    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
630    UnknownValue(serde_json::Value),
631}
632
633/// UpdateIncidentTypeError is a struct for typed errors of method [`IncidentsAPI::update_incident_type`]
634#[derive(Debug, Clone, Serialize, Deserialize)]
635#[serde(untagged)]
636pub enum UpdateIncidentTypeError {
637    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
638    UnknownValue(serde_json::Value),
639}
640
641/// Manage incident response, as well as associated attachments, metadata, and todos. See the [Incident Management page](<https://docs.datadoghq.com/service_management/incident_management/>) for more information.
642#[derive(Debug, Clone)]
643pub struct IncidentsAPI {
644    config: datadog::Configuration,
645    client: reqwest_middleware::ClientWithMiddleware,
646}
647
648impl Default for IncidentsAPI {
649    fn default() -> Self {
650        Self::with_config(datadog::Configuration::default())
651    }
652}
653
654impl IncidentsAPI {
655    pub fn new() -> Self {
656        Self::default()
657    }
658    pub fn with_config(config: datadog::Configuration) -> Self {
659        let mut reqwest_client_builder = reqwest::Client::builder();
660
661        if let Some(proxy_url) = &config.proxy_url {
662            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
663            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
664        }
665
666        let mut middleware_client_builder =
667            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
668
669        if config.enable_retry {
670            struct RetryableStatus;
671            impl reqwest_retry::RetryableStrategy for RetryableStatus {
672                fn handle(
673                    &self,
674                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
675                ) -> Option<reqwest_retry::Retryable> {
676                    match res {
677                        Ok(success) => reqwest_retry::default_on_request_success(success),
678                        Err(_) => None,
679                    }
680                }
681            }
682            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
683                .build_with_max_retries(config.max_retries);
684
685            let retry_middleware =
686                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
687                    backoff_policy,
688                    RetryableStatus,
689                );
690
691            middleware_client_builder = middleware_client_builder.with(retry_middleware);
692        }
693
694        let client = middleware_client_builder.build();
695
696        Self { config, client }
697    }
698
699    pub fn with_client_and_config(
700        config: datadog::Configuration,
701        client: reqwest_middleware::ClientWithMiddleware,
702    ) -> Self {
703        Self { config, client }
704    }
705
706    /// Create an incident.
707    pub async fn create_incident(
708        &self,
709        body: crate::datadogV2::model::IncidentCreateRequest,
710    ) -> Result<crate::datadogV2::model::IncidentResponse, datadog::Error<CreateIncidentError>>
711    {
712        match self.create_incident_with_http_info(body).await {
713            Ok(response_content) => {
714                if let Some(e) = response_content.entity {
715                    Ok(e)
716                } else {
717                    Err(datadog::Error::Serde(serde::de::Error::custom(
718                        "response content was None",
719                    )))
720                }
721            }
722            Err(err) => Err(err),
723        }
724    }
725
726    /// Create an incident.
727    pub async fn create_incident_with_http_info(
728        &self,
729        body: crate::datadogV2::model::IncidentCreateRequest,
730    ) -> Result<
731        datadog::ResponseContent<crate::datadogV2::model::IncidentResponse>,
732        datadog::Error<CreateIncidentError>,
733    > {
734        let local_configuration = &self.config;
735        let operation_id = "v2.create_incident";
736        if local_configuration.is_unstable_operation_enabled(operation_id) {
737            warn!("Using unstable operation {operation_id}");
738        } else {
739            let local_error = datadog::UnstableOperationDisabledError {
740                msg: "Operation 'v2.create_incident' is not enabled".to_string(),
741            };
742            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
743        }
744
745        let local_client = &self.client;
746
747        let local_uri_str = format!(
748            "{}/api/v2/incidents",
749            local_configuration.get_operation_host(operation_id)
750        );
751        let mut local_req_builder =
752            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
753
754        // build headers
755        let mut headers = HeaderMap::new();
756        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
757        headers.insert("Accept", HeaderValue::from_static("application/json"));
758
759        // build user agent
760        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
761            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
762            Err(e) => {
763                log::warn!("Failed to parse user agent header: {e}, falling back to default");
764                headers.insert(
765                    reqwest::header::USER_AGENT,
766                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
767                )
768            }
769        };
770
771        // build auth
772        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
773            headers.insert(
774                "DD-API-KEY",
775                HeaderValue::from_str(local_key.key.as_str())
776                    .expect("failed to parse DD-API-KEY header"),
777            );
778        };
779        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
780            headers.insert(
781                "DD-APPLICATION-KEY",
782                HeaderValue::from_str(local_key.key.as_str())
783                    .expect("failed to parse DD-APPLICATION-KEY header"),
784            );
785        };
786
787        // build body parameters
788        let output = Vec::new();
789        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
790        if body.serialize(&mut ser).is_ok() {
791            if let Some(content_encoding) = headers.get("Content-Encoding") {
792                match content_encoding.to_str().unwrap_or_default() {
793                    "gzip" => {
794                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
795                        let _ = enc.write_all(ser.into_inner().as_slice());
796                        match enc.finish() {
797                            Ok(buf) => {
798                                local_req_builder = local_req_builder.body(buf);
799                            }
800                            Err(e) => return Err(datadog::Error::Io(e)),
801                        }
802                    }
803                    "deflate" => {
804                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
805                        let _ = enc.write_all(ser.into_inner().as_slice());
806                        match enc.finish() {
807                            Ok(buf) => {
808                                local_req_builder = local_req_builder.body(buf);
809                            }
810                            Err(e) => return Err(datadog::Error::Io(e)),
811                        }
812                    }
813                    "zstd1" => {
814                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
815                        let _ = enc.write_all(ser.into_inner().as_slice());
816                        match enc.finish() {
817                            Ok(buf) => {
818                                local_req_builder = local_req_builder.body(buf);
819                            }
820                            Err(e) => return Err(datadog::Error::Io(e)),
821                        }
822                    }
823                    _ => {
824                        local_req_builder = local_req_builder.body(ser.into_inner());
825                    }
826                }
827            } else {
828                local_req_builder = local_req_builder.body(ser.into_inner());
829            }
830        }
831
832        local_req_builder = local_req_builder.headers(headers);
833        let local_req = local_req_builder.build()?;
834        log::debug!("request content: {:?}", local_req.body());
835        let local_resp = local_client.execute(local_req).await?;
836
837        let local_status = local_resp.status();
838        let local_content = local_resp.text().await?;
839        log::debug!("response content: {}", local_content);
840
841        if !local_status.is_client_error() && !local_status.is_server_error() {
842            match serde_json::from_str::<crate::datadogV2::model::IncidentResponse>(&local_content)
843            {
844                Ok(e) => {
845                    return Ok(datadog::ResponseContent {
846                        status: local_status,
847                        content: local_content,
848                        entity: Some(e),
849                    })
850                }
851                Err(e) => return Err(datadog::Error::Serde(e)),
852            };
853        } else {
854            let local_entity: Option<CreateIncidentError> =
855                serde_json::from_str(&local_content).ok();
856            let local_error = datadog::ResponseContent {
857                status: local_status,
858                content: local_content,
859                entity: local_entity,
860            };
861            Err(datadog::Error::ResponseError(local_error))
862        }
863    }
864
865    /// Create an impact for an incident.
866    pub async fn create_incident_impact(
867        &self,
868        incident_id: String,
869        body: crate::datadogV2::model::IncidentImpactCreateRequest,
870        params: CreateIncidentImpactOptionalParams,
871    ) -> Result<
872        crate::datadogV2::model::IncidentImpactResponse,
873        datadog::Error<CreateIncidentImpactError>,
874    > {
875        match self
876            .create_incident_impact_with_http_info(incident_id, body, params)
877            .await
878        {
879            Ok(response_content) => {
880                if let Some(e) = response_content.entity {
881                    Ok(e)
882                } else {
883                    Err(datadog::Error::Serde(serde::de::Error::custom(
884                        "response content was None",
885                    )))
886                }
887            }
888            Err(err) => Err(err),
889        }
890    }
891
892    /// Create an impact for an incident.
893    pub async fn create_incident_impact_with_http_info(
894        &self,
895        incident_id: String,
896        body: crate::datadogV2::model::IncidentImpactCreateRequest,
897        params: CreateIncidentImpactOptionalParams,
898    ) -> Result<
899        datadog::ResponseContent<crate::datadogV2::model::IncidentImpactResponse>,
900        datadog::Error<CreateIncidentImpactError>,
901    > {
902        let local_configuration = &self.config;
903        let operation_id = "v2.create_incident_impact";
904        if local_configuration.is_unstable_operation_enabled(operation_id) {
905            warn!("Using unstable operation {operation_id}");
906        } else {
907            let local_error = datadog::UnstableOperationDisabledError {
908                msg: "Operation 'v2.create_incident_impact' is not enabled".to_string(),
909            };
910            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
911        }
912
913        // unbox and build optional parameters
914        let include = params.include;
915
916        let local_client = &self.client;
917
918        let local_uri_str = format!(
919            "{}/api/v2/incidents/{incident_id}/impacts",
920            local_configuration.get_operation_host(operation_id),
921            incident_id = datadog::urlencode(incident_id)
922        );
923        let mut local_req_builder =
924            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
925
926        if let Some(ref local) = include {
927            local_req_builder = local_req_builder.query(&[(
928                "include",
929                &local
930                    .iter()
931                    .map(|p| p.to_string())
932                    .collect::<Vec<String>>()
933                    .join(",")
934                    .to_string(),
935            )]);
936        };
937
938        // build headers
939        let mut headers = HeaderMap::new();
940        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
941        headers.insert("Accept", HeaderValue::from_static("application/json"));
942
943        // build user agent
944        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
945            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
946            Err(e) => {
947                log::warn!("Failed to parse user agent header: {e}, falling back to default");
948                headers.insert(
949                    reqwest::header::USER_AGENT,
950                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
951                )
952            }
953        };
954
955        // build auth
956        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
957            headers.insert(
958                "DD-API-KEY",
959                HeaderValue::from_str(local_key.key.as_str())
960                    .expect("failed to parse DD-API-KEY header"),
961            );
962        };
963        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
964            headers.insert(
965                "DD-APPLICATION-KEY",
966                HeaderValue::from_str(local_key.key.as_str())
967                    .expect("failed to parse DD-APPLICATION-KEY header"),
968            );
969        };
970
971        // build body parameters
972        let output = Vec::new();
973        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
974        if body.serialize(&mut ser).is_ok() {
975            if let Some(content_encoding) = headers.get("Content-Encoding") {
976                match content_encoding.to_str().unwrap_or_default() {
977                    "gzip" => {
978                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
979                        let _ = enc.write_all(ser.into_inner().as_slice());
980                        match enc.finish() {
981                            Ok(buf) => {
982                                local_req_builder = local_req_builder.body(buf);
983                            }
984                            Err(e) => return Err(datadog::Error::Io(e)),
985                        }
986                    }
987                    "deflate" => {
988                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
989                        let _ = enc.write_all(ser.into_inner().as_slice());
990                        match enc.finish() {
991                            Ok(buf) => {
992                                local_req_builder = local_req_builder.body(buf);
993                            }
994                            Err(e) => return Err(datadog::Error::Io(e)),
995                        }
996                    }
997                    "zstd1" => {
998                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
999                        let _ = enc.write_all(ser.into_inner().as_slice());
1000                        match enc.finish() {
1001                            Ok(buf) => {
1002                                local_req_builder = local_req_builder.body(buf);
1003                            }
1004                            Err(e) => return Err(datadog::Error::Io(e)),
1005                        }
1006                    }
1007                    _ => {
1008                        local_req_builder = local_req_builder.body(ser.into_inner());
1009                    }
1010                }
1011            } else {
1012                local_req_builder = local_req_builder.body(ser.into_inner());
1013            }
1014        }
1015
1016        local_req_builder = local_req_builder.headers(headers);
1017        let local_req = local_req_builder.build()?;
1018        log::debug!("request content: {:?}", local_req.body());
1019        let local_resp = local_client.execute(local_req).await?;
1020
1021        let local_status = local_resp.status();
1022        let local_content = local_resp.text().await?;
1023        log::debug!("response content: {}", local_content);
1024
1025        if !local_status.is_client_error() && !local_status.is_server_error() {
1026            match serde_json::from_str::<crate::datadogV2::model::IncidentImpactResponse>(
1027                &local_content,
1028            ) {
1029                Ok(e) => {
1030                    return Ok(datadog::ResponseContent {
1031                        status: local_status,
1032                        content: local_content,
1033                        entity: Some(e),
1034                    })
1035                }
1036                Err(e) => return Err(datadog::Error::Serde(e)),
1037            };
1038        } else {
1039            let local_entity: Option<CreateIncidentImpactError> =
1040                serde_json::from_str(&local_content).ok();
1041            let local_error = datadog::ResponseContent {
1042                status: local_status,
1043                content: local_content,
1044                entity: local_entity,
1045            };
1046            Err(datadog::Error::ResponseError(local_error))
1047        }
1048    }
1049
1050    /// Create an incident integration metadata.
1051    pub async fn create_incident_integration(
1052        &self,
1053        incident_id: String,
1054        body: crate::datadogV2::model::IncidentIntegrationMetadataCreateRequest,
1055    ) -> Result<
1056        crate::datadogV2::model::IncidentIntegrationMetadataResponse,
1057        datadog::Error<CreateIncidentIntegrationError>,
1058    > {
1059        match self
1060            .create_incident_integration_with_http_info(incident_id, body)
1061            .await
1062        {
1063            Ok(response_content) => {
1064                if let Some(e) = response_content.entity {
1065                    Ok(e)
1066                } else {
1067                    Err(datadog::Error::Serde(serde::de::Error::custom(
1068                        "response content was None",
1069                    )))
1070                }
1071            }
1072            Err(err) => Err(err),
1073        }
1074    }
1075
1076    /// Create an incident integration metadata.
1077    pub async fn create_incident_integration_with_http_info(
1078        &self,
1079        incident_id: String,
1080        body: crate::datadogV2::model::IncidentIntegrationMetadataCreateRequest,
1081    ) -> Result<
1082        datadog::ResponseContent<crate::datadogV2::model::IncidentIntegrationMetadataResponse>,
1083        datadog::Error<CreateIncidentIntegrationError>,
1084    > {
1085        let local_configuration = &self.config;
1086        let operation_id = "v2.create_incident_integration";
1087        if local_configuration.is_unstable_operation_enabled(operation_id) {
1088            warn!("Using unstable operation {operation_id}");
1089        } else {
1090            let local_error = datadog::UnstableOperationDisabledError {
1091                msg: "Operation 'v2.create_incident_integration' is not enabled".to_string(),
1092            };
1093            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1094        }
1095
1096        let local_client = &self.client;
1097
1098        let local_uri_str = format!(
1099            "{}/api/v2/incidents/{incident_id}/relationships/integrations",
1100            local_configuration.get_operation_host(operation_id),
1101            incident_id = datadog::urlencode(incident_id)
1102        );
1103        let mut local_req_builder =
1104            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1105
1106        // build headers
1107        let mut headers = HeaderMap::new();
1108        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1109        headers.insert("Accept", HeaderValue::from_static("application/json"));
1110
1111        // build user agent
1112        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1113            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1114            Err(e) => {
1115                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1116                headers.insert(
1117                    reqwest::header::USER_AGENT,
1118                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1119                )
1120            }
1121        };
1122
1123        // build auth
1124        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1125            headers.insert(
1126                "DD-API-KEY",
1127                HeaderValue::from_str(local_key.key.as_str())
1128                    .expect("failed to parse DD-API-KEY header"),
1129            );
1130        };
1131        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1132            headers.insert(
1133                "DD-APPLICATION-KEY",
1134                HeaderValue::from_str(local_key.key.as_str())
1135                    .expect("failed to parse DD-APPLICATION-KEY header"),
1136            );
1137        };
1138
1139        // build body parameters
1140        let output = Vec::new();
1141        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1142        if body.serialize(&mut ser).is_ok() {
1143            if let Some(content_encoding) = headers.get("Content-Encoding") {
1144                match content_encoding.to_str().unwrap_or_default() {
1145                    "gzip" => {
1146                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1147                        let _ = enc.write_all(ser.into_inner().as_slice());
1148                        match enc.finish() {
1149                            Ok(buf) => {
1150                                local_req_builder = local_req_builder.body(buf);
1151                            }
1152                            Err(e) => return Err(datadog::Error::Io(e)),
1153                        }
1154                    }
1155                    "deflate" => {
1156                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1157                        let _ = enc.write_all(ser.into_inner().as_slice());
1158                        match enc.finish() {
1159                            Ok(buf) => {
1160                                local_req_builder = local_req_builder.body(buf);
1161                            }
1162                            Err(e) => return Err(datadog::Error::Io(e)),
1163                        }
1164                    }
1165                    "zstd1" => {
1166                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1167                        let _ = enc.write_all(ser.into_inner().as_slice());
1168                        match enc.finish() {
1169                            Ok(buf) => {
1170                                local_req_builder = local_req_builder.body(buf);
1171                            }
1172                            Err(e) => return Err(datadog::Error::Io(e)),
1173                        }
1174                    }
1175                    _ => {
1176                        local_req_builder = local_req_builder.body(ser.into_inner());
1177                    }
1178                }
1179            } else {
1180                local_req_builder = local_req_builder.body(ser.into_inner());
1181            }
1182        }
1183
1184        local_req_builder = local_req_builder.headers(headers);
1185        let local_req = local_req_builder.build()?;
1186        log::debug!("request content: {:?}", local_req.body());
1187        let local_resp = local_client.execute(local_req).await?;
1188
1189        let local_status = local_resp.status();
1190        let local_content = local_resp.text().await?;
1191        log::debug!("response content: {}", local_content);
1192
1193        if !local_status.is_client_error() && !local_status.is_server_error() {
1194            match serde_json::from_str::<crate::datadogV2::model::IncidentIntegrationMetadataResponse>(
1195                &local_content,
1196            ) {
1197                Ok(e) => {
1198                    return Ok(datadog::ResponseContent {
1199                        status: local_status,
1200                        content: local_content,
1201                        entity: Some(e),
1202                    })
1203                }
1204                Err(e) => return Err(datadog::Error::Serde(e)),
1205            };
1206        } else {
1207            let local_entity: Option<CreateIncidentIntegrationError> =
1208                serde_json::from_str(&local_content).ok();
1209            let local_error = datadog::ResponseContent {
1210                status: local_status,
1211                content: local_content,
1212                entity: local_entity,
1213            };
1214            Err(datadog::Error::ResponseError(local_error))
1215        }
1216    }
1217
1218    /// Creates a new notification rule.
1219    pub async fn create_incident_notification_rule(
1220        &self,
1221        body: crate::datadogV2::model::CreateIncidentNotificationRuleRequest,
1222    ) -> Result<
1223        crate::datadogV2::model::IncidentNotificationRule,
1224        datadog::Error<CreateIncidentNotificationRuleError>,
1225    > {
1226        match self
1227            .create_incident_notification_rule_with_http_info(body)
1228            .await
1229        {
1230            Ok(response_content) => {
1231                if let Some(e) = response_content.entity {
1232                    Ok(e)
1233                } else {
1234                    Err(datadog::Error::Serde(serde::de::Error::custom(
1235                        "response content was None",
1236                    )))
1237                }
1238            }
1239            Err(err) => Err(err),
1240        }
1241    }
1242
1243    /// Creates a new notification rule.
1244    pub async fn create_incident_notification_rule_with_http_info(
1245        &self,
1246        body: crate::datadogV2::model::CreateIncidentNotificationRuleRequest,
1247    ) -> Result<
1248        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationRule>,
1249        datadog::Error<CreateIncidentNotificationRuleError>,
1250    > {
1251        let local_configuration = &self.config;
1252        let operation_id = "v2.create_incident_notification_rule";
1253        if local_configuration.is_unstable_operation_enabled(operation_id) {
1254            warn!("Using unstable operation {operation_id}");
1255        } else {
1256            let local_error = datadog::UnstableOperationDisabledError {
1257                msg: "Operation 'v2.create_incident_notification_rule' is not enabled".to_string(),
1258            };
1259            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1260        }
1261
1262        let local_client = &self.client;
1263
1264        let local_uri_str = format!(
1265            "{}/api/v2/incidents/config/notification-rules",
1266            local_configuration.get_operation_host(operation_id)
1267        );
1268        let mut local_req_builder =
1269            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1270
1271        // build headers
1272        let mut headers = HeaderMap::new();
1273        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1274        headers.insert("Accept", HeaderValue::from_static("application/json"));
1275
1276        // build user agent
1277        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1278            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1279            Err(e) => {
1280                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1281                headers.insert(
1282                    reqwest::header::USER_AGENT,
1283                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1284                )
1285            }
1286        };
1287
1288        // build auth
1289        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1290            headers.insert(
1291                "DD-API-KEY",
1292                HeaderValue::from_str(local_key.key.as_str())
1293                    .expect("failed to parse DD-API-KEY header"),
1294            );
1295        };
1296        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1297            headers.insert(
1298                "DD-APPLICATION-KEY",
1299                HeaderValue::from_str(local_key.key.as_str())
1300                    .expect("failed to parse DD-APPLICATION-KEY header"),
1301            );
1302        };
1303
1304        // build body parameters
1305        let output = Vec::new();
1306        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1307        if body.serialize(&mut ser).is_ok() {
1308            if let Some(content_encoding) = headers.get("Content-Encoding") {
1309                match content_encoding.to_str().unwrap_or_default() {
1310                    "gzip" => {
1311                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1312                        let _ = enc.write_all(ser.into_inner().as_slice());
1313                        match enc.finish() {
1314                            Ok(buf) => {
1315                                local_req_builder = local_req_builder.body(buf);
1316                            }
1317                            Err(e) => return Err(datadog::Error::Io(e)),
1318                        }
1319                    }
1320                    "deflate" => {
1321                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1322                        let _ = enc.write_all(ser.into_inner().as_slice());
1323                        match enc.finish() {
1324                            Ok(buf) => {
1325                                local_req_builder = local_req_builder.body(buf);
1326                            }
1327                            Err(e) => return Err(datadog::Error::Io(e)),
1328                        }
1329                    }
1330                    "zstd1" => {
1331                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1332                        let _ = enc.write_all(ser.into_inner().as_slice());
1333                        match enc.finish() {
1334                            Ok(buf) => {
1335                                local_req_builder = local_req_builder.body(buf);
1336                            }
1337                            Err(e) => return Err(datadog::Error::Io(e)),
1338                        }
1339                    }
1340                    _ => {
1341                        local_req_builder = local_req_builder.body(ser.into_inner());
1342                    }
1343                }
1344            } else {
1345                local_req_builder = local_req_builder.body(ser.into_inner());
1346            }
1347        }
1348
1349        local_req_builder = local_req_builder.headers(headers);
1350        let local_req = local_req_builder.build()?;
1351        log::debug!("request content: {:?}", local_req.body());
1352        let local_resp = local_client.execute(local_req).await?;
1353
1354        let local_status = local_resp.status();
1355        let local_content = local_resp.text().await?;
1356        log::debug!("response content: {}", local_content);
1357
1358        if !local_status.is_client_error() && !local_status.is_server_error() {
1359            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationRule>(
1360                &local_content,
1361            ) {
1362                Ok(e) => {
1363                    return Ok(datadog::ResponseContent {
1364                        status: local_status,
1365                        content: local_content,
1366                        entity: Some(e),
1367                    })
1368                }
1369                Err(e) => return Err(datadog::Error::Serde(e)),
1370            };
1371        } else {
1372            let local_entity: Option<CreateIncidentNotificationRuleError> =
1373                serde_json::from_str(&local_content).ok();
1374            let local_error = datadog::ResponseContent {
1375                status: local_status,
1376                content: local_content,
1377                entity: local_entity,
1378            };
1379            Err(datadog::Error::ResponseError(local_error))
1380        }
1381    }
1382
1383    /// Creates a new notification template.
1384    pub async fn create_incident_notification_template(
1385        &self,
1386        body: crate::datadogV2::model::CreateIncidentNotificationTemplateRequest,
1387    ) -> Result<
1388        crate::datadogV2::model::IncidentNotificationTemplate,
1389        datadog::Error<CreateIncidentNotificationTemplateError>,
1390    > {
1391        match self
1392            .create_incident_notification_template_with_http_info(body)
1393            .await
1394        {
1395            Ok(response_content) => {
1396                if let Some(e) = response_content.entity {
1397                    Ok(e)
1398                } else {
1399                    Err(datadog::Error::Serde(serde::de::Error::custom(
1400                        "response content was None",
1401                    )))
1402                }
1403            }
1404            Err(err) => Err(err),
1405        }
1406    }
1407
1408    /// Creates a new notification template.
1409    pub async fn create_incident_notification_template_with_http_info(
1410        &self,
1411        body: crate::datadogV2::model::CreateIncidentNotificationTemplateRequest,
1412    ) -> Result<
1413        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationTemplate>,
1414        datadog::Error<CreateIncidentNotificationTemplateError>,
1415    > {
1416        let local_configuration = &self.config;
1417        let operation_id = "v2.create_incident_notification_template";
1418        if local_configuration.is_unstable_operation_enabled(operation_id) {
1419            warn!("Using unstable operation {operation_id}");
1420        } else {
1421            let local_error = datadog::UnstableOperationDisabledError {
1422                msg: "Operation 'v2.create_incident_notification_template' is not enabled"
1423                    .to_string(),
1424            };
1425            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1426        }
1427
1428        let local_client = &self.client;
1429
1430        let local_uri_str = format!(
1431            "{}/api/v2/incidents/config/notification-templates",
1432            local_configuration.get_operation_host(operation_id)
1433        );
1434        let mut local_req_builder =
1435            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1436
1437        // build headers
1438        let mut headers = HeaderMap::new();
1439        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1440        headers.insert("Accept", HeaderValue::from_static("application/json"));
1441
1442        // build user agent
1443        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1444            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1445            Err(e) => {
1446                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1447                headers.insert(
1448                    reqwest::header::USER_AGENT,
1449                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1450                )
1451            }
1452        };
1453
1454        // build auth
1455        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1456            headers.insert(
1457                "DD-API-KEY",
1458                HeaderValue::from_str(local_key.key.as_str())
1459                    .expect("failed to parse DD-API-KEY header"),
1460            );
1461        };
1462        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1463            headers.insert(
1464                "DD-APPLICATION-KEY",
1465                HeaderValue::from_str(local_key.key.as_str())
1466                    .expect("failed to parse DD-APPLICATION-KEY header"),
1467            );
1468        };
1469
1470        // build body parameters
1471        let output = Vec::new();
1472        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1473        if body.serialize(&mut ser).is_ok() {
1474            if let Some(content_encoding) = headers.get("Content-Encoding") {
1475                match content_encoding.to_str().unwrap_or_default() {
1476                    "gzip" => {
1477                        let mut enc = GzEncoder::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                    "deflate" => {
1487                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
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                    "zstd1" => {
1497                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1498                        let _ = enc.write_all(ser.into_inner().as_slice());
1499                        match enc.finish() {
1500                            Ok(buf) => {
1501                                local_req_builder = local_req_builder.body(buf);
1502                            }
1503                            Err(e) => return Err(datadog::Error::Io(e)),
1504                        }
1505                    }
1506                    _ => {
1507                        local_req_builder = local_req_builder.body(ser.into_inner());
1508                    }
1509                }
1510            } else {
1511                local_req_builder = local_req_builder.body(ser.into_inner());
1512            }
1513        }
1514
1515        local_req_builder = local_req_builder.headers(headers);
1516        let local_req = local_req_builder.build()?;
1517        log::debug!("request content: {:?}", local_req.body());
1518        let local_resp = local_client.execute(local_req).await?;
1519
1520        let local_status = local_resp.status();
1521        let local_content = local_resp.text().await?;
1522        log::debug!("response content: {}", local_content);
1523
1524        if !local_status.is_client_error() && !local_status.is_server_error() {
1525            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationTemplate>(
1526                &local_content,
1527            ) {
1528                Ok(e) => {
1529                    return Ok(datadog::ResponseContent {
1530                        status: local_status,
1531                        content: local_content,
1532                        entity: Some(e),
1533                    })
1534                }
1535                Err(e) => return Err(datadog::Error::Serde(e)),
1536            };
1537        } else {
1538            let local_entity: Option<CreateIncidentNotificationTemplateError> =
1539                serde_json::from_str(&local_content).ok();
1540            let local_error = datadog::ResponseContent {
1541                status: local_status,
1542                content: local_content,
1543                entity: local_entity,
1544            };
1545            Err(datadog::Error::ResponseError(local_error))
1546        }
1547    }
1548
1549    /// Create an incident todo.
1550    pub async fn create_incident_todo(
1551        &self,
1552        incident_id: String,
1553        body: crate::datadogV2::model::IncidentTodoCreateRequest,
1554    ) -> Result<
1555        crate::datadogV2::model::IncidentTodoResponse,
1556        datadog::Error<CreateIncidentTodoError>,
1557    > {
1558        match self
1559            .create_incident_todo_with_http_info(incident_id, body)
1560            .await
1561        {
1562            Ok(response_content) => {
1563                if let Some(e) = response_content.entity {
1564                    Ok(e)
1565                } else {
1566                    Err(datadog::Error::Serde(serde::de::Error::custom(
1567                        "response content was None",
1568                    )))
1569                }
1570            }
1571            Err(err) => Err(err),
1572        }
1573    }
1574
1575    /// Create an incident todo.
1576    pub async fn create_incident_todo_with_http_info(
1577        &self,
1578        incident_id: String,
1579        body: crate::datadogV2::model::IncidentTodoCreateRequest,
1580    ) -> Result<
1581        datadog::ResponseContent<crate::datadogV2::model::IncidentTodoResponse>,
1582        datadog::Error<CreateIncidentTodoError>,
1583    > {
1584        let local_configuration = &self.config;
1585        let operation_id = "v2.create_incident_todo";
1586        if local_configuration.is_unstable_operation_enabled(operation_id) {
1587            warn!("Using unstable operation {operation_id}");
1588        } else {
1589            let local_error = datadog::UnstableOperationDisabledError {
1590                msg: "Operation 'v2.create_incident_todo' is not enabled".to_string(),
1591            };
1592            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1593        }
1594
1595        let local_client = &self.client;
1596
1597        let local_uri_str = format!(
1598            "{}/api/v2/incidents/{incident_id}/relationships/todos",
1599            local_configuration.get_operation_host(operation_id),
1600            incident_id = datadog::urlencode(incident_id)
1601        );
1602        let mut local_req_builder =
1603            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1604
1605        // build headers
1606        let mut headers = HeaderMap::new();
1607        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1608        headers.insert("Accept", HeaderValue::from_static("application/json"));
1609
1610        // build user agent
1611        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1612            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1613            Err(e) => {
1614                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1615                headers.insert(
1616                    reqwest::header::USER_AGENT,
1617                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1618                )
1619            }
1620        };
1621
1622        // build auth
1623        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1624            headers.insert(
1625                "DD-API-KEY",
1626                HeaderValue::from_str(local_key.key.as_str())
1627                    .expect("failed to parse DD-API-KEY header"),
1628            );
1629        };
1630        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1631            headers.insert(
1632                "DD-APPLICATION-KEY",
1633                HeaderValue::from_str(local_key.key.as_str())
1634                    .expect("failed to parse DD-APPLICATION-KEY header"),
1635            );
1636        };
1637
1638        // build body parameters
1639        let output = Vec::new();
1640        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1641        if body.serialize(&mut ser).is_ok() {
1642            if let Some(content_encoding) = headers.get("Content-Encoding") {
1643                match content_encoding.to_str().unwrap_or_default() {
1644                    "gzip" => {
1645                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1646                        let _ = enc.write_all(ser.into_inner().as_slice());
1647                        match enc.finish() {
1648                            Ok(buf) => {
1649                                local_req_builder = local_req_builder.body(buf);
1650                            }
1651                            Err(e) => return Err(datadog::Error::Io(e)),
1652                        }
1653                    }
1654                    "deflate" => {
1655                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1656                        let _ = enc.write_all(ser.into_inner().as_slice());
1657                        match enc.finish() {
1658                            Ok(buf) => {
1659                                local_req_builder = local_req_builder.body(buf);
1660                            }
1661                            Err(e) => return Err(datadog::Error::Io(e)),
1662                        }
1663                    }
1664                    "zstd1" => {
1665                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1666                        let _ = enc.write_all(ser.into_inner().as_slice());
1667                        match enc.finish() {
1668                            Ok(buf) => {
1669                                local_req_builder = local_req_builder.body(buf);
1670                            }
1671                            Err(e) => return Err(datadog::Error::Io(e)),
1672                        }
1673                    }
1674                    _ => {
1675                        local_req_builder = local_req_builder.body(ser.into_inner());
1676                    }
1677                }
1678            } else {
1679                local_req_builder = local_req_builder.body(ser.into_inner());
1680            }
1681        }
1682
1683        local_req_builder = local_req_builder.headers(headers);
1684        let local_req = local_req_builder.build()?;
1685        log::debug!("request content: {:?}", local_req.body());
1686        let local_resp = local_client.execute(local_req).await?;
1687
1688        let local_status = local_resp.status();
1689        let local_content = local_resp.text().await?;
1690        log::debug!("response content: {}", local_content);
1691
1692        if !local_status.is_client_error() && !local_status.is_server_error() {
1693            match serde_json::from_str::<crate::datadogV2::model::IncidentTodoResponse>(
1694                &local_content,
1695            ) {
1696                Ok(e) => {
1697                    return Ok(datadog::ResponseContent {
1698                        status: local_status,
1699                        content: local_content,
1700                        entity: Some(e),
1701                    })
1702                }
1703                Err(e) => return Err(datadog::Error::Serde(e)),
1704            };
1705        } else {
1706            let local_entity: Option<CreateIncidentTodoError> =
1707                serde_json::from_str(&local_content).ok();
1708            let local_error = datadog::ResponseContent {
1709                status: local_status,
1710                content: local_content,
1711                entity: local_entity,
1712            };
1713            Err(datadog::Error::ResponseError(local_error))
1714        }
1715    }
1716
1717    /// Create an incident type.
1718    pub async fn create_incident_type(
1719        &self,
1720        body: crate::datadogV2::model::IncidentTypeCreateRequest,
1721    ) -> Result<
1722        crate::datadogV2::model::IncidentTypeResponse,
1723        datadog::Error<CreateIncidentTypeError>,
1724    > {
1725        match self.create_incident_type_with_http_info(body).await {
1726            Ok(response_content) => {
1727                if let Some(e) = response_content.entity {
1728                    Ok(e)
1729                } else {
1730                    Err(datadog::Error::Serde(serde::de::Error::custom(
1731                        "response content was None",
1732                    )))
1733                }
1734            }
1735            Err(err) => Err(err),
1736        }
1737    }
1738
1739    /// Create an incident type.
1740    pub async fn create_incident_type_with_http_info(
1741        &self,
1742        body: crate::datadogV2::model::IncidentTypeCreateRequest,
1743    ) -> Result<
1744        datadog::ResponseContent<crate::datadogV2::model::IncidentTypeResponse>,
1745        datadog::Error<CreateIncidentTypeError>,
1746    > {
1747        let local_configuration = &self.config;
1748        let operation_id = "v2.create_incident_type";
1749        if local_configuration.is_unstable_operation_enabled(operation_id) {
1750            warn!("Using unstable operation {operation_id}");
1751        } else {
1752            let local_error = datadog::UnstableOperationDisabledError {
1753                msg: "Operation 'v2.create_incident_type' is not enabled".to_string(),
1754            };
1755            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1756        }
1757
1758        let local_client = &self.client;
1759
1760        let local_uri_str = format!(
1761            "{}/api/v2/incidents/config/types",
1762            local_configuration.get_operation_host(operation_id)
1763        );
1764        let mut local_req_builder =
1765            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1766
1767        // build headers
1768        let mut headers = HeaderMap::new();
1769        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1770        headers.insert("Accept", HeaderValue::from_static("application/json"));
1771
1772        // build user agent
1773        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1774            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1775            Err(e) => {
1776                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1777                headers.insert(
1778                    reqwest::header::USER_AGENT,
1779                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1780                )
1781            }
1782        };
1783
1784        // build auth
1785        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1786            headers.insert(
1787                "DD-API-KEY",
1788                HeaderValue::from_str(local_key.key.as_str())
1789                    .expect("failed to parse DD-API-KEY header"),
1790            );
1791        };
1792        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1793            headers.insert(
1794                "DD-APPLICATION-KEY",
1795                HeaderValue::from_str(local_key.key.as_str())
1796                    .expect("failed to parse DD-APPLICATION-KEY header"),
1797            );
1798        };
1799
1800        // build body parameters
1801        let output = Vec::new();
1802        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1803        if body.serialize(&mut ser).is_ok() {
1804            if let Some(content_encoding) = headers.get("Content-Encoding") {
1805                match content_encoding.to_str().unwrap_or_default() {
1806                    "gzip" => {
1807                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1808                        let _ = enc.write_all(ser.into_inner().as_slice());
1809                        match enc.finish() {
1810                            Ok(buf) => {
1811                                local_req_builder = local_req_builder.body(buf);
1812                            }
1813                            Err(e) => return Err(datadog::Error::Io(e)),
1814                        }
1815                    }
1816                    "deflate" => {
1817                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1818                        let _ = enc.write_all(ser.into_inner().as_slice());
1819                        match enc.finish() {
1820                            Ok(buf) => {
1821                                local_req_builder = local_req_builder.body(buf);
1822                            }
1823                            Err(e) => return Err(datadog::Error::Io(e)),
1824                        }
1825                    }
1826                    "zstd1" => {
1827                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1828                        let _ = enc.write_all(ser.into_inner().as_slice());
1829                        match enc.finish() {
1830                            Ok(buf) => {
1831                                local_req_builder = local_req_builder.body(buf);
1832                            }
1833                            Err(e) => return Err(datadog::Error::Io(e)),
1834                        }
1835                    }
1836                    _ => {
1837                        local_req_builder = local_req_builder.body(ser.into_inner());
1838                    }
1839                }
1840            } else {
1841                local_req_builder = local_req_builder.body(ser.into_inner());
1842            }
1843        }
1844
1845        local_req_builder = local_req_builder.headers(headers);
1846        let local_req = local_req_builder.build()?;
1847        log::debug!("request content: {:?}", local_req.body());
1848        let local_resp = local_client.execute(local_req).await?;
1849
1850        let local_status = local_resp.status();
1851        let local_content = local_resp.text().await?;
1852        log::debug!("response content: {}", local_content);
1853
1854        if !local_status.is_client_error() && !local_status.is_server_error() {
1855            match serde_json::from_str::<crate::datadogV2::model::IncidentTypeResponse>(
1856                &local_content,
1857            ) {
1858                Ok(e) => {
1859                    return Ok(datadog::ResponseContent {
1860                        status: local_status,
1861                        content: local_content,
1862                        entity: Some(e),
1863                    })
1864                }
1865                Err(e) => return Err(datadog::Error::Serde(e)),
1866            };
1867        } else {
1868            let local_entity: Option<CreateIncidentTypeError> =
1869                serde_json::from_str(&local_content).ok();
1870            let local_error = datadog::ResponseContent {
1871                status: local_status,
1872                content: local_content,
1873                entity: local_entity,
1874            };
1875            Err(datadog::Error::ResponseError(local_error))
1876        }
1877    }
1878
1879    /// Deletes an existing incident from the users organization.
1880    pub async fn delete_incident(
1881        &self,
1882        incident_id: String,
1883    ) -> Result<(), datadog::Error<DeleteIncidentError>> {
1884        match self.delete_incident_with_http_info(incident_id).await {
1885            Ok(_) => Ok(()),
1886            Err(err) => Err(err),
1887        }
1888    }
1889
1890    /// Deletes an existing incident from the users organization.
1891    pub async fn delete_incident_with_http_info(
1892        &self,
1893        incident_id: String,
1894    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentError>> {
1895        let local_configuration = &self.config;
1896        let operation_id = "v2.delete_incident";
1897        if local_configuration.is_unstable_operation_enabled(operation_id) {
1898            warn!("Using unstable operation {operation_id}");
1899        } else {
1900            let local_error = datadog::UnstableOperationDisabledError {
1901                msg: "Operation 'v2.delete_incident' is not enabled".to_string(),
1902            };
1903            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1904        }
1905
1906        let local_client = &self.client;
1907
1908        let local_uri_str = format!(
1909            "{}/api/v2/incidents/{incident_id}",
1910            local_configuration.get_operation_host(operation_id),
1911            incident_id = datadog::urlencode(incident_id)
1912        );
1913        let mut local_req_builder =
1914            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1915
1916        // build headers
1917        let mut headers = HeaderMap::new();
1918        headers.insert("Accept", HeaderValue::from_static("*/*"));
1919
1920        // build user agent
1921        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1922            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1923            Err(e) => {
1924                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1925                headers.insert(
1926                    reqwest::header::USER_AGENT,
1927                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1928                )
1929            }
1930        };
1931
1932        // build auth
1933        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1934            headers.insert(
1935                "DD-API-KEY",
1936                HeaderValue::from_str(local_key.key.as_str())
1937                    .expect("failed to parse DD-API-KEY header"),
1938            );
1939        };
1940        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1941            headers.insert(
1942                "DD-APPLICATION-KEY",
1943                HeaderValue::from_str(local_key.key.as_str())
1944                    .expect("failed to parse DD-APPLICATION-KEY header"),
1945            );
1946        };
1947
1948        local_req_builder = local_req_builder.headers(headers);
1949        let local_req = local_req_builder.build()?;
1950        log::debug!("request content: {:?}", local_req.body());
1951        let local_resp = local_client.execute(local_req).await?;
1952
1953        let local_status = local_resp.status();
1954        let local_content = local_resp.text().await?;
1955        log::debug!("response content: {}", local_content);
1956
1957        if !local_status.is_client_error() && !local_status.is_server_error() {
1958            Ok(datadog::ResponseContent {
1959                status: local_status,
1960                content: local_content,
1961                entity: None,
1962            })
1963        } else {
1964            let local_entity: Option<DeleteIncidentError> =
1965                serde_json::from_str(&local_content).ok();
1966            let local_error = datadog::ResponseContent {
1967                status: local_status,
1968                content: local_content,
1969                entity: local_entity,
1970            };
1971            Err(datadog::Error::ResponseError(local_error))
1972        }
1973    }
1974
1975    /// Delete an incident impact.
1976    pub async fn delete_incident_impact(
1977        &self,
1978        incident_id: String,
1979        impact_id: String,
1980    ) -> Result<(), datadog::Error<DeleteIncidentImpactError>> {
1981        match self
1982            .delete_incident_impact_with_http_info(incident_id, impact_id)
1983            .await
1984        {
1985            Ok(_) => Ok(()),
1986            Err(err) => Err(err),
1987        }
1988    }
1989
1990    /// Delete an incident impact.
1991    pub async fn delete_incident_impact_with_http_info(
1992        &self,
1993        incident_id: String,
1994        impact_id: String,
1995    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentImpactError>> {
1996        let local_configuration = &self.config;
1997        let operation_id = "v2.delete_incident_impact";
1998        if local_configuration.is_unstable_operation_enabled(operation_id) {
1999            warn!("Using unstable operation {operation_id}");
2000        } else {
2001            let local_error = datadog::UnstableOperationDisabledError {
2002                msg: "Operation 'v2.delete_incident_impact' is not enabled".to_string(),
2003            };
2004            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2005        }
2006
2007        let local_client = &self.client;
2008
2009        let local_uri_str = format!(
2010            "{}/api/v2/incidents/{incident_id}/impacts/{impact_id}",
2011            local_configuration.get_operation_host(operation_id),
2012            incident_id = datadog::urlencode(incident_id),
2013            impact_id = datadog::urlencode(impact_id)
2014        );
2015        let mut local_req_builder =
2016            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2017
2018        // build headers
2019        let mut headers = HeaderMap::new();
2020        headers.insert("Accept", HeaderValue::from_static("*/*"));
2021
2022        // build user agent
2023        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2024            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2025            Err(e) => {
2026                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2027                headers.insert(
2028                    reqwest::header::USER_AGENT,
2029                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2030                )
2031            }
2032        };
2033
2034        // build auth
2035        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2036            headers.insert(
2037                "DD-API-KEY",
2038                HeaderValue::from_str(local_key.key.as_str())
2039                    .expect("failed to parse DD-API-KEY header"),
2040            );
2041        };
2042        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2043            headers.insert(
2044                "DD-APPLICATION-KEY",
2045                HeaderValue::from_str(local_key.key.as_str())
2046                    .expect("failed to parse DD-APPLICATION-KEY header"),
2047            );
2048        };
2049
2050        local_req_builder = local_req_builder.headers(headers);
2051        let local_req = local_req_builder.build()?;
2052        log::debug!("request content: {:?}", local_req.body());
2053        let local_resp = local_client.execute(local_req).await?;
2054
2055        let local_status = local_resp.status();
2056        let local_content = local_resp.text().await?;
2057        log::debug!("response content: {}", local_content);
2058
2059        if !local_status.is_client_error() && !local_status.is_server_error() {
2060            Ok(datadog::ResponseContent {
2061                status: local_status,
2062                content: local_content,
2063                entity: None,
2064            })
2065        } else {
2066            let local_entity: Option<DeleteIncidentImpactError> =
2067                serde_json::from_str(&local_content).ok();
2068            let local_error = datadog::ResponseContent {
2069                status: local_status,
2070                content: local_content,
2071                entity: local_entity,
2072            };
2073            Err(datadog::Error::ResponseError(local_error))
2074        }
2075    }
2076
2077    /// Delete an incident integration metadata.
2078    pub async fn delete_incident_integration(
2079        &self,
2080        incident_id: String,
2081        integration_metadata_id: String,
2082    ) -> Result<(), datadog::Error<DeleteIncidentIntegrationError>> {
2083        match self
2084            .delete_incident_integration_with_http_info(incident_id, integration_metadata_id)
2085            .await
2086        {
2087            Ok(_) => Ok(()),
2088            Err(err) => Err(err),
2089        }
2090    }
2091
2092    /// Delete an incident integration metadata.
2093    pub async fn delete_incident_integration_with_http_info(
2094        &self,
2095        incident_id: String,
2096        integration_metadata_id: String,
2097    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentIntegrationError>> {
2098        let local_configuration = &self.config;
2099        let operation_id = "v2.delete_incident_integration";
2100        if local_configuration.is_unstable_operation_enabled(operation_id) {
2101            warn!("Using unstable operation {operation_id}");
2102        } else {
2103            let local_error = datadog::UnstableOperationDisabledError {
2104                msg: "Operation 'v2.delete_incident_integration' is not enabled".to_string(),
2105            };
2106            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2107        }
2108
2109        let local_client = &self.client;
2110
2111        let local_uri_str = format!(
2112            "{}/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}",
2113            local_configuration.get_operation_host(operation_id), incident_id=
2114            datadog::urlencode(incident_id)
2115            , integration_metadata_id=
2116            datadog::urlencode(integration_metadata_id)
2117            );
2118        let mut local_req_builder =
2119            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2120
2121        // build headers
2122        let mut headers = HeaderMap::new();
2123        headers.insert("Accept", HeaderValue::from_static("*/*"));
2124
2125        // build user agent
2126        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2127            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2128            Err(e) => {
2129                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2130                headers.insert(
2131                    reqwest::header::USER_AGENT,
2132                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2133                )
2134            }
2135        };
2136
2137        // build auth
2138        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2139            headers.insert(
2140                "DD-API-KEY",
2141                HeaderValue::from_str(local_key.key.as_str())
2142                    .expect("failed to parse DD-API-KEY header"),
2143            );
2144        };
2145        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2146            headers.insert(
2147                "DD-APPLICATION-KEY",
2148                HeaderValue::from_str(local_key.key.as_str())
2149                    .expect("failed to parse DD-APPLICATION-KEY header"),
2150            );
2151        };
2152
2153        local_req_builder = local_req_builder.headers(headers);
2154        let local_req = local_req_builder.build()?;
2155        log::debug!("request content: {:?}", local_req.body());
2156        let local_resp = local_client.execute(local_req).await?;
2157
2158        let local_status = local_resp.status();
2159        let local_content = local_resp.text().await?;
2160        log::debug!("response content: {}", local_content);
2161
2162        if !local_status.is_client_error() && !local_status.is_server_error() {
2163            Ok(datadog::ResponseContent {
2164                status: local_status,
2165                content: local_content,
2166                entity: None,
2167            })
2168        } else {
2169            let local_entity: Option<DeleteIncidentIntegrationError> =
2170                serde_json::from_str(&local_content).ok();
2171            let local_error = datadog::ResponseContent {
2172                status: local_status,
2173                content: local_content,
2174                entity: local_entity,
2175            };
2176            Err(datadog::Error::ResponseError(local_error))
2177        }
2178    }
2179
2180    /// Deletes a notification rule by its ID.
2181    pub async fn delete_incident_notification_rule(
2182        &self,
2183        id: uuid::Uuid,
2184        params: DeleteIncidentNotificationRuleOptionalParams,
2185    ) -> Result<(), datadog::Error<DeleteIncidentNotificationRuleError>> {
2186        match self
2187            .delete_incident_notification_rule_with_http_info(id, params)
2188            .await
2189        {
2190            Ok(_) => Ok(()),
2191            Err(err) => Err(err),
2192        }
2193    }
2194
2195    /// Deletes a notification rule by its ID.
2196    pub async fn delete_incident_notification_rule_with_http_info(
2197        &self,
2198        id: uuid::Uuid,
2199        params: DeleteIncidentNotificationRuleOptionalParams,
2200    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentNotificationRuleError>>
2201    {
2202        let local_configuration = &self.config;
2203        let operation_id = "v2.delete_incident_notification_rule";
2204        if local_configuration.is_unstable_operation_enabled(operation_id) {
2205            warn!("Using unstable operation {operation_id}");
2206        } else {
2207            let local_error = datadog::UnstableOperationDisabledError {
2208                msg: "Operation 'v2.delete_incident_notification_rule' is not enabled".to_string(),
2209            };
2210            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2211        }
2212
2213        // unbox and build optional parameters
2214        let include = params.include;
2215
2216        let local_client = &self.client;
2217
2218        let local_uri_str = format!(
2219            "{}/api/v2/incidents/config/notification-rules/{id}",
2220            local_configuration.get_operation_host(operation_id),
2221            id = datadog::urlencode(id.to_string())
2222        );
2223        let mut local_req_builder =
2224            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2225
2226        if let Some(ref local_query_param) = include {
2227            local_req_builder =
2228                local_req_builder.query(&[("include", &local_query_param.to_string())]);
2229        };
2230
2231        // build headers
2232        let mut headers = HeaderMap::new();
2233        headers.insert("Accept", HeaderValue::from_static("*/*"));
2234
2235        // build user agent
2236        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2237            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2238            Err(e) => {
2239                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2240                headers.insert(
2241                    reqwest::header::USER_AGENT,
2242                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2243                )
2244            }
2245        };
2246
2247        // build auth
2248        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2249            headers.insert(
2250                "DD-API-KEY",
2251                HeaderValue::from_str(local_key.key.as_str())
2252                    .expect("failed to parse DD-API-KEY header"),
2253            );
2254        };
2255        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2256            headers.insert(
2257                "DD-APPLICATION-KEY",
2258                HeaderValue::from_str(local_key.key.as_str())
2259                    .expect("failed to parse DD-APPLICATION-KEY header"),
2260            );
2261        };
2262
2263        local_req_builder = local_req_builder.headers(headers);
2264        let local_req = local_req_builder.build()?;
2265        log::debug!("request content: {:?}", local_req.body());
2266        let local_resp = local_client.execute(local_req).await?;
2267
2268        let local_status = local_resp.status();
2269        let local_content = local_resp.text().await?;
2270        log::debug!("response content: {}", local_content);
2271
2272        if !local_status.is_client_error() && !local_status.is_server_error() {
2273            Ok(datadog::ResponseContent {
2274                status: local_status,
2275                content: local_content,
2276                entity: None,
2277            })
2278        } else {
2279            let local_entity: Option<DeleteIncidentNotificationRuleError> =
2280                serde_json::from_str(&local_content).ok();
2281            let local_error = datadog::ResponseContent {
2282                status: local_status,
2283                content: local_content,
2284                entity: local_entity,
2285            };
2286            Err(datadog::Error::ResponseError(local_error))
2287        }
2288    }
2289
2290    /// Deletes a notification template by its ID.
2291    pub async fn delete_incident_notification_template(
2292        &self,
2293        id: uuid::Uuid,
2294        params: DeleteIncidentNotificationTemplateOptionalParams,
2295    ) -> Result<(), datadog::Error<DeleteIncidentNotificationTemplateError>> {
2296        match self
2297            .delete_incident_notification_template_with_http_info(id, params)
2298            .await
2299        {
2300            Ok(_) => Ok(()),
2301            Err(err) => Err(err),
2302        }
2303    }
2304
2305    /// Deletes a notification template by its ID.
2306    pub async fn delete_incident_notification_template_with_http_info(
2307        &self,
2308        id: uuid::Uuid,
2309        params: DeleteIncidentNotificationTemplateOptionalParams,
2310    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentNotificationTemplateError>>
2311    {
2312        let local_configuration = &self.config;
2313        let operation_id = "v2.delete_incident_notification_template";
2314        if local_configuration.is_unstable_operation_enabled(operation_id) {
2315            warn!("Using unstable operation {operation_id}");
2316        } else {
2317            let local_error = datadog::UnstableOperationDisabledError {
2318                msg: "Operation 'v2.delete_incident_notification_template' is not enabled"
2319                    .to_string(),
2320            };
2321            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2322        }
2323
2324        // unbox and build optional parameters
2325        let include = params.include;
2326
2327        let local_client = &self.client;
2328
2329        let local_uri_str = format!(
2330            "{}/api/v2/incidents/config/notification-templates/{id}",
2331            local_configuration.get_operation_host(operation_id),
2332            id = datadog::urlencode(id.to_string())
2333        );
2334        let mut local_req_builder =
2335            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2336
2337        if let Some(ref local_query_param) = include {
2338            local_req_builder =
2339                local_req_builder.query(&[("include", &local_query_param.to_string())]);
2340        };
2341
2342        // build headers
2343        let mut headers = HeaderMap::new();
2344        headers.insert("Accept", HeaderValue::from_static("*/*"));
2345
2346        // build user agent
2347        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2348            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2349            Err(e) => {
2350                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2351                headers.insert(
2352                    reqwest::header::USER_AGENT,
2353                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2354                )
2355            }
2356        };
2357
2358        // build auth
2359        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2360            headers.insert(
2361                "DD-API-KEY",
2362                HeaderValue::from_str(local_key.key.as_str())
2363                    .expect("failed to parse DD-API-KEY header"),
2364            );
2365        };
2366        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2367            headers.insert(
2368                "DD-APPLICATION-KEY",
2369                HeaderValue::from_str(local_key.key.as_str())
2370                    .expect("failed to parse DD-APPLICATION-KEY header"),
2371            );
2372        };
2373
2374        local_req_builder = local_req_builder.headers(headers);
2375        let local_req = local_req_builder.build()?;
2376        log::debug!("request content: {:?}", local_req.body());
2377        let local_resp = local_client.execute(local_req).await?;
2378
2379        let local_status = local_resp.status();
2380        let local_content = local_resp.text().await?;
2381        log::debug!("response content: {}", local_content);
2382
2383        if !local_status.is_client_error() && !local_status.is_server_error() {
2384            Ok(datadog::ResponseContent {
2385                status: local_status,
2386                content: local_content,
2387                entity: None,
2388            })
2389        } else {
2390            let local_entity: Option<DeleteIncidentNotificationTemplateError> =
2391                serde_json::from_str(&local_content).ok();
2392            let local_error = datadog::ResponseContent {
2393                status: local_status,
2394                content: local_content,
2395                entity: local_entity,
2396            };
2397            Err(datadog::Error::ResponseError(local_error))
2398        }
2399    }
2400
2401    /// Delete an incident todo.
2402    pub async fn delete_incident_todo(
2403        &self,
2404        incident_id: String,
2405        todo_id: String,
2406    ) -> Result<(), datadog::Error<DeleteIncidentTodoError>> {
2407        match self
2408            .delete_incident_todo_with_http_info(incident_id, todo_id)
2409            .await
2410        {
2411            Ok(_) => Ok(()),
2412            Err(err) => Err(err),
2413        }
2414    }
2415
2416    /// Delete an incident todo.
2417    pub async fn delete_incident_todo_with_http_info(
2418        &self,
2419        incident_id: String,
2420        todo_id: String,
2421    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentTodoError>> {
2422        let local_configuration = &self.config;
2423        let operation_id = "v2.delete_incident_todo";
2424        if local_configuration.is_unstable_operation_enabled(operation_id) {
2425            warn!("Using unstable operation {operation_id}");
2426        } else {
2427            let local_error = datadog::UnstableOperationDisabledError {
2428                msg: "Operation 'v2.delete_incident_todo' is not enabled".to_string(),
2429            };
2430            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2431        }
2432
2433        let local_client = &self.client;
2434
2435        let local_uri_str = format!(
2436            "{}/api/v2/incidents/{incident_id}/relationships/todos/{todo_id}",
2437            local_configuration.get_operation_host(operation_id),
2438            incident_id = datadog::urlencode(incident_id),
2439            todo_id = datadog::urlencode(todo_id)
2440        );
2441        let mut local_req_builder =
2442            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2443
2444        // build headers
2445        let mut headers = HeaderMap::new();
2446        headers.insert("Accept", HeaderValue::from_static("*/*"));
2447
2448        // build user agent
2449        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2450            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2451            Err(e) => {
2452                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2453                headers.insert(
2454                    reqwest::header::USER_AGENT,
2455                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2456                )
2457            }
2458        };
2459
2460        // build auth
2461        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2462            headers.insert(
2463                "DD-API-KEY",
2464                HeaderValue::from_str(local_key.key.as_str())
2465                    .expect("failed to parse DD-API-KEY header"),
2466            );
2467        };
2468        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2469            headers.insert(
2470                "DD-APPLICATION-KEY",
2471                HeaderValue::from_str(local_key.key.as_str())
2472                    .expect("failed to parse DD-APPLICATION-KEY header"),
2473            );
2474        };
2475
2476        local_req_builder = local_req_builder.headers(headers);
2477        let local_req = local_req_builder.build()?;
2478        log::debug!("request content: {:?}", local_req.body());
2479        let local_resp = local_client.execute(local_req).await?;
2480
2481        let local_status = local_resp.status();
2482        let local_content = local_resp.text().await?;
2483        log::debug!("response content: {}", local_content);
2484
2485        if !local_status.is_client_error() && !local_status.is_server_error() {
2486            Ok(datadog::ResponseContent {
2487                status: local_status,
2488                content: local_content,
2489                entity: None,
2490            })
2491        } else {
2492            let local_entity: Option<DeleteIncidentTodoError> =
2493                serde_json::from_str(&local_content).ok();
2494            let local_error = datadog::ResponseContent {
2495                status: local_status,
2496                content: local_content,
2497                entity: local_entity,
2498            };
2499            Err(datadog::Error::ResponseError(local_error))
2500        }
2501    }
2502
2503    /// Delete an incident type.
2504    pub async fn delete_incident_type(
2505        &self,
2506        incident_type_id: String,
2507    ) -> Result<(), datadog::Error<DeleteIncidentTypeError>> {
2508        match self
2509            .delete_incident_type_with_http_info(incident_type_id)
2510            .await
2511        {
2512            Ok(_) => Ok(()),
2513            Err(err) => Err(err),
2514        }
2515    }
2516
2517    /// Delete an incident type.
2518    pub async fn delete_incident_type_with_http_info(
2519        &self,
2520        incident_type_id: String,
2521    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIncidentTypeError>> {
2522        let local_configuration = &self.config;
2523        let operation_id = "v2.delete_incident_type";
2524        if local_configuration.is_unstable_operation_enabled(operation_id) {
2525            warn!("Using unstable operation {operation_id}");
2526        } else {
2527            let local_error = datadog::UnstableOperationDisabledError {
2528                msg: "Operation 'v2.delete_incident_type' is not enabled".to_string(),
2529            };
2530            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2531        }
2532
2533        let local_client = &self.client;
2534
2535        let local_uri_str = format!(
2536            "{}/api/v2/incidents/config/types/{incident_type_id}",
2537            local_configuration.get_operation_host(operation_id),
2538            incident_type_id = datadog::urlencode(incident_type_id)
2539        );
2540        let mut local_req_builder =
2541            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2542
2543        // build headers
2544        let mut headers = HeaderMap::new();
2545        headers.insert("Accept", HeaderValue::from_static("*/*"));
2546
2547        // build user agent
2548        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2549            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2550            Err(e) => {
2551                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2552                headers.insert(
2553                    reqwest::header::USER_AGENT,
2554                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2555                )
2556            }
2557        };
2558
2559        // build auth
2560        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2561            headers.insert(
2562                "DD-API-KEY",
2563                HeaderValue::from_str(local_key.key.as_str())
2564                    .expect("failed to parse DD-API-KEY header"),
2565            );
2566        };
2567        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2568            headers.insert(
2569                "DD-APPLICATION-KEY",
2570                HeaderValue::from_str(local_key.key.as_str())
2571                    .expect("failed to parse DD-APPLICATION-KEY header"),
2572            );
2573        };
2574
2575        local_req_builder = local_req_builder.headers(headers);
2576        let local_req = local_req_builder.build()?;
2577        log::debug!("request content: {:?}", local_req.body());
2578        let local_resp = local_client.execute(local_req).await?;
2579
2580        let local_status = local_resp.status();
2581        let local_content = local_resp.text().await?;
2582        log::debug!("response content: {}", local_content);
2583
2584        if !local_status.is_client_error() && !local_status.is_server_error() {
2585            Ok(datadog::ResponseContent {
2586                status: local_status,
2587                content: local_content,
2588                entity: None,
2589            })
2590        } else {
2591            let local_entity: Option<DeleteIncidentTypeError> =
2592                serde_json::from_str(&local_content).ok();
2593            let local_error = datadog::ResponseContent {
2594                status: local_status,
2595                content: local_content,
2596                entity: local_entity,
2597            };
2598            Err(datadog::Error::ResponseError(local_error))
2599        }
2600    }
2601
2602    /// Get the details of an incident by `incident_id`.
2603    pub async fn get_incident(
2604        &self,
2605        incident_id: String,
2606        params: GetIncidentOptionalParams,
2607    ) -> Result<crate::datadogV2::model::IncidentResponse, datadog::Error<GetIncidentError>> {
2608        match self.get_incident_with_http_info(incident_id, params).await {
2609            Ok(response_content) => {
2610                if let Some(e) = response_content.entity {
2611                    Ok(e)
2612                } else {
2613                    Err(datadog::Error::Serde(serde::de::Error::custom(
2614                        "response content was None",
2615                    )))
2616                }
2617            }
2618            Err(err) => Err(err),
2619        }
2620    }
2621
2622    /// Get the details of an incident by `incident_id`.
2623    pub async fn get_incident_with_http_info(
2624        &self,
2625        incident_id: String,
2626        params: GetIncidentOptionalParams,
2627    ) -> Result<
2628        datadog::ResponseContent<crate::datadogV2::model::IncidentResponse>,
2629        datadog::Error<GetIncidentError>,
2630    > {
2631        let local_configuration = &self.config;
2632        let operation_id = "v2.get_incident";
2633        if local_configuration.is_unstable_operation_enabled(operation_id) {
2634            warn!("Using unstable operation {operation_id}");
2635        } else {
2636            let local_error = datadog::UnstableOperationDisabledError {
2637                msg: "Operation 'v2.get_incident' is not enabled".to_string(),
2638            };
2639            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2640        }
2641
2642        // unbox and build optional parameters
2643        let include = params.include;
2644
2645        let local_client = &self.client;
2646
2647        let local_uri_str = format!(
2648            "{}/api/v2/incidents/{incident_id}",
2649            local_configuration.get_operation_host(operation_id),
2650            incident_id = datadog::urlencode(incident_id)
2651        );
2652        let mut local_req_builder =
2653            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2654
2655        if let Some(ref local) = include {
2656            local_req_builder = local_req_builder.query(&[(
2657                "include",
2658                &local
2659                    .iter()
2660                    .map(|p| p.to_string())
2661                    .collect::<Vec<String>>()
2662                    .join(",")
2663                    .to_string(),
2664            )]);
2665        };
2666
2667        // build headers
2668        let mut headers = HeaderMap::new();
2669        headers.insert("Accept", HeaderValue::from_static("application/json"));
2670
2671        // build user agent
2672        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2673            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2674            Err(e) => {
2675                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2676                headers.insert(
2677                    reqwest::header::USER_AGENT,
2678                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2679                )
2680            }
2681        };
2682
2683        // build auth
2684        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2685            headers.insert(
2686                "DD-API-KEY",
2687                HeaderValue::from_str(local_key.key.as_str())
2688                    .expect("failed to parse DD-API-KEY header"),
2689            );
2690        };
2691        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2692            headers.insert(
2693                "DD-APPLICATION-KEY",
2694                HeaderValue::from_str(local_key.key.as_str())
2695                    .expect("failed to parse DD-APPLICATION-KEY header"),
2696            );
2697        };
2698
2699        local_req_builder = local_req_builder.headers(headers);
2700        let local_req = local_req_builder.build()?;
2701        log::debug!("request content: {:?}", local_req.body());
2702        let local_resp = local_client.execute(local_req).await?;
2703
2704        let local_status = local_resp.status();
2705        let local_content = local_resp.text().await?;
2706        log::debug!("response content: {}", local_content);
2707
2708        if !local_status.is_client_error() && !local_status.is_server_error() {
2709            match serde_json::from_str::<crate::datadogV2::model::IncidentResponse>(&local_content)
2710            {
2711                Ok(e) => {
2712                    return Ok(datadog::ResponseContent {
2713                        status: local_status,
2714                        content: local_content,
2715                        entity: Some(e),
2716                    })
2717                }
2718                Err(e) => return Err(datadog::Error::Serde(e)),
2719            };
2720        } else {
2721            let local_entity: Option<GetIncidentError> = serde_json::from_str(&local_content).ok();
2722            let local_error = datadog::ResponseContent {
2723                status: local_status,
2724                content: local_content,
2725                entity: local_entity,
2726            };
2727            Err(datadog::Error::ResponseError(local_error))
2728        }
2729    }
2730
2731    /// Get incident integration metadata details.
2732    pub async fn get_incident_integration(
2733        &self,
2734        incident_id: String,
2735        integration_metadata_id: String,
2736    ) -> Result<
2737        crate::datadogV2::model::IncidentIntegrationMetadataResponse,
2738        datadog::Error<GetIncidentIntegrationError>,
2739    > {
2740        match self
2741            .get_incident_integration_with_http_info(incident_id, integration_metadata_id)
2742            .await
2743        {
2744            Ok(response_content) => {
2745                if let Some(e) = response_content.entity {
2746                    Ok(e)
2747                } else {
2748                    Err(datadog::Error::Serde(serde::de::Error::custom(
2749                        "response content was None",
2750                    )))
2751                }
2752            }
2753            Err(err) => Err(err),
2754        }
2755    }
2756
2757    /// Get incident integration metadata details.
2758    pub async fn get_incident_integration_with_http_info(
2759        &self,
2760        incident_id: String,
2761        integration_metadata_id: String,
2762    ) -> Result<
2763        datadog::ResponseContent<crate::datadogV2::model::IncidentIntegrationMetadataResponse>,
2764        datadog::Error<GetIncidentIntegrationError>,
2765    > {
2766        let local_configuration = &self.config;
2767        let operation_id = "v2.get_incident_integration";
2768        if local_configuration.is_unstable_operation_enabled(operation_id) {
2769            warn!("Using unstable operation {operation_id}");
2770        } else {
2771            let local_error = datadog::UnstableOperationDisabledError {
2772                msg: "Operation 'v2.get_incident_integration' is not enabled".to_string(),
2773            };
2774            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2775        }
2776
2777        let local_client = &self.client;
2778
2779        let local_uri_str = format!(
2780            "{}/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}",
2781            local_configuration.get_operation_host(operation_id), incident_id=
2782            datadog::urlencode(incident_id)
2783            , integration_metadata_id=
2784            datadog::urlencode(integration_metadata_id)
2785            );
2786        let mut local_req_builder =
2787            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2788
2789        // build headers
2790        let mut headers = HeaderMap::new();
2791        headers.insert("Accept", HeaderValue::from_static("application/json"));
2792
2793        // build user agent
2794        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2795            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2796            Err(e) => {
2797                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2798                headers.insert(
2799                    reqwest::header::USER_AGENT,
2800                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2801                )
2802            }
2803        };
2804
2805        // build auth
2806        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2807            headers.insert(
2808                "DD-API-KEY",
2809                HeaderValue::from_str(local_key.key.as_str())
2810                    .expect("failed to parse DD-API-KEY header"),
2811            );
2812        };
2813        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2814            headers.insert(
2815                "DD-APPLICATION-KEY",
2816                HeaderValue::from_str(local_key.key.as_str())
2817                    .expect("failed to parse DD-APPLICATION-KEY header"),
2818            );
2819        };
2820
2821        local_req_builder = local_req_builder.headers(headers);
2822        let local_req = local_req_builder.build()?;
2823        log::debug!("request content: {:?}", local_req.body());
2824        let local_resp = local_client.execute(local_req).await?;
2825
2826        let local_status = local_resp.status();
2827        let local_content = local_resp.text().await?;
2828        log::debug!("response content: {}", local_content);
2829
2830        if !local_status.is_client_error() && !local_status.is_server_error() {
2831            match serde_json::from_str::<crate::datadogV2::model::IncidentIntegrationMetadataResponse>(
2832                &local_content,
2833            ) {
2834                Ok(e) => {
2835                    return Ok(datadog::ResponseContent {
2836                        status: local_status,
2837                        content: local_content,
2838                        entity: Some(e),
2839                    })
2840                }
2841                Err(e) => return Err(datadog::Error::Serde(e)),
2842            };
2843        } else {
2844            let local_entity: Option<GetIncidentIntegrationError> =
2845                serde_json::from_str(&local_content).ok();
2846            let local_error = datadog::ResponseContent {
2847                status: local_status,
2848                content: local_content,
2849                entity: local_entity,
2850            };
2851            Err(datadog::Error::ResponseError(local_error))
2852        }
2853    }
2854
2855    /// Retrieves a specific notification rule by its ID.
2856    pub async fn get_incident_notification_rule(
2857        &self,
2858        id: uuid::Uuid,
2859        params: GetIncidentNotificationRuleOptionalParams,
2860    ) -> Result<
2861        crate::datadogV2::model::IncidentNotificationRule,
2862        datadog::Error<GetIncidentNotificationRuleError>,
2863    > {
2864        match self
2865            .get_incident_notification_rule_with_http_info(id, params)
2866            .await
2867        {
2868            Ok(response_content) => {
2869                if let Some(e) = response_content.entity {
2870                    Ok(e)
2871                } else {
2872                    Err(datadog::Error::Serde(serde::de::Error::custom(
2873                        "response content was None",
2874                    )))
2875                }
2876            }
2877            Err(err) => Err(err),
2878        }
2879    }
2880
2881    /// Retrieves a specific notification rule by its ID.
2882    pub async fn get_incident_notification_rule_with_http_info(
2883        &self,
2884        id: uuid::Uuid,
2885        params: GetIncidentNotificationRuleOptionalParams,
2886    ) -> Result<
2887        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationRule>,
2888        datadog::Error<GetIncidentNotificationRuleError>,
2889    > {
2890        let local_configuration = &self.config;
2891        let operation_id = "v2.get_incident_notification_rule";
2892        if local_configuration.is_unstable_operation_enabled(operation_id) {
2893            warn!("Using unstable operation {operation_id}");
2894        } else {
2895            let local_error = datadog::UnstableOperationDisabledError {
2896                msg: "Operation 'v2.get_incident_notification_rule' is not enabled".to_string(),
2897            };
2898            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2899        }
2900
2901        // unbox and build optional parameters
2902        let include = params.include;
2903
2904        let local_client = &self.client;
2905
2906        let local_uri_str = format!(
2907            "{}/api/v2/incidents/config/notification-rules/{id}",
2908            local_configuration.get_operation_host(operation_id),
2909            id = datadog::urlencode(id.to_string())
2910        );
2911        let mut local_req_builder =
2912            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2913
2914        if let Some(ref local_query_param) = include {
2915            local_req_builder =
2916                local_req_builder.query(&[("include", &local_query_param.to_string())]);
2917        };
2918
2919        // build headers
2920        let mut headers = HeaderMap::new();
2921        headers.insert("Accept", HeaderValue::from_static("application/json"));
2922
2923        // build user agent
2924        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2925            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2926            Err(e) => {
2927                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2928                headers.insert(
2929                    reqwest::header::USER_AGENT,
2930                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2931                )
2932            }
2933        };
2934
2935        // build auth
2936        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2937            headers.insert(
2938                "DD-API-KEY",
2939                HeaderValue::from_str(local_key.key.as_str())
2940                    .expect("failed to parse DD-API-KEY header"),
2941            );
2942        };
2943        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2944            headers.insert(
2945                "DD-APPLICATION-KEY",
2946                HeaderValue::from_str(local_key.key.as_str())
2947                    .expect("failed to parse DD-APPLICATION-KEY header"),
2948            );
2949        };
2950
2951        local_req_builder = local_req_builder.headers(headers);
2952        let local_req = local_req_builder.build()?;
2953        log::debug!("request content: {:?}", local_req.body());
2954        let local_resp = local_client.execute(local_req).await?;
2955
2956        let local_status = local_resp.status();
2957        let local_content = local_resp.text().await?;
2958        log::debug!("response content: {}", local_content);
2959
2960        if !local_status.is_client_error() && !local_status.is_server_error() {
2961            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationRule>(
2962                &local_content,
2963            ) {
2964                Ok(e) => {
2965                    return Ok(datadog::ResponseContent {
2966                        status: local_status,
2967                        content: local_content,
2968                        entity: Some(e),
2969                    })
2970                }
2971                Err(e) => return Err(datadog::Error::Serde(e)),
2972            };
2973        } else {
2974            let local_entity: Option<GetIncidentNotificationRuleError> =
2975                serde_json::from_str(&local_content).ok();
2976            let local_error = datadog::ResponseContent {
2977                status: local_status,
2978                content: local_content,
2979                entity: local_entity,
2980            };
2981            Err(datadog::Error::ResponseError(local_error))
2982        }
2983    }
2984
2985    /// Retrieves a specific notification template by its ID.
2986    pub async fn get_incident_notification_template(
2987        &self,
2988        id: uuid::Uuid,
2989        params: GetIncidentNotificationTemplateOptionalParams,
2990    ) -> Result<
2991        crate::datadogV2::model::IncidentNotificationTemplate,
2992        datadog::Error<GetIncidentNotificationTemplateError>,
2993    > {
2994        match self
2995            .get_incident_notification_template_with_http_info(id, params)
2996            .await
2997        {
2998            Ok(response_content) => {
2999                if let Some(e) = response_content.entity {
3000                    Ok(e)
3001                } else {
3002                    Err(datadog::Error::Serde(serde::de::Error::custom(
3003                        "response content was None",
3004                    )))
3005                }
3006            }
3007            Err(err) => Err(err),
3008        }
3009    }
3010
3011    /// Retrieves a specific notification template by its ID.
3012    pub async fn get_incident_notification_template_with_http_info(
3013        &self,
3014        id: uuid::Uuid,
3015        params: GetIncidentNotificationTemplateOptionalParams,
3016    ) -> Result<
3017        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationTemplate>,
3018        datadog::Error<GetIncidentNotificationTemplateError>,
3019    > {
3020        let local_configuration = &self.config;
3021        let operation_id = "v2.get_incident_notification_template";
3022        if local_configuration.is_unstable_operation_enabled(operation_id) {
3023            warn!("Using unstable operation {operation_id}");
3024        } else {
3025            let local_error = datadog::UnstableOperationDisabledError {
3026                msg: "Operation 'v2.get_incident_notification_template' is not enabled".to_string(),
3027            };
3028            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3029        }
3030
3031        // unbox and build optional parameters
3032        let include = params.include;
3033
3034        let local_client = &self.client;
3035
3036        let local_uri_str = format!(
3037            "{}/api/v2/incidents/config/notification-templates/{id}",
3038            local_configuration.get_operation_host(operation_id),
3039            id = datadog::urlencode(id.to_string())
3040        );
3041        let mut local_req_builder =
3042            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3043
3044        if let Some(ref local_query_param) = include {
3045            local_req_builder =
3046                local_req_builder.query(&[("include", &local_query_param.to_string())]);
3047        };
3048
3049        // build headers
3050        let mut headers = HeaderMap::new();
3051        headers.insert("Accept", HeaderValue::from_static("application/json"));
3052
3053        // build user agent
3054        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3055            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3056            Err(e) => {
3057                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3058                headers.insert(
3059                    reqwest::header::USER_AGENT,
3060                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3061                )
3062            }
3063        };
3064
3065        // build auth
3066        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3067            headers.insert(
3068                "DD-API-KEY",
3069                HeaderValue::from_str(local_key.key.as_str())
3070                    .expect("failed to parse DD-API-KEY header"),
3071            );
3072        };
3073        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3074            headers.insert(
3075                "DD-APPLICATION-KEY",
3076                HeaderValue::from_str(local_key.key.as_str())
3077                    .expect("failed to parse DD-APPLICATION-KEY header"),
3078            );
3079        };
3080
3081        local_req_builder = local_req_builder.headers(headers);
3082        let local_req = local_req_builder.build()?;
3083        log::debug!("request content: {:?}", local_req.body());
3084        let local_resp = local_client.execute(local_req).await?;
3085
3086        let local_status = local_resp.status();
3087        let local_content = local_resp.text().await?;
3088        log::debug!("response content: {}", local_content);
3089
3090        if !local_status.is_client_error() && !local_status.is_server_error() {
3091            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationTemplate>(
3092                &local_content,
3093            ) {
3094                Ok(e) => {
3095                    return Ok(datadog::ResponseContent {
3096                        status: local_status,
3097                        content: local_content,
3098                        entity: Some(e),
3099                    })
3100                }
3101                Err(e) => return Err(datadog::Error::Serde(e)),
3102            };
3103        } else {
3104            let local_entity: Option<GetIncidentNotificationTemplateError> =
3105                serde_json::from_str(&local_content).ok();
3106            let local_error = datadog::ResponseContent {
3107                status: local_status,
3108                content: local_content,
3109                entity: local_entity,
3110            };
3111            Err(datadog::Error::ResponseError(local_error))
3112        }
3113    }
3114
3115    /// Get incident todo details.
3116    pub async fn get_incident_todo(
3117        &self,
3118        incident_id: String,
3119        todo_id: String,
3120    ) -> Result<crate::datadogV2::model::IncidentTodoResponse, datadog::Error<GetIncidentTodoError>>
3121    {
3122        match self
3123            .get_incident_todo_with_http_info(incident_id, todo_id)
3124            .await
3125        {
3126            Ok(response_content) => {
3127                if let Some(e) = response_content.entity {
3128                    Ok(e)
3129                } else {
3130                    Err(datadog::Error::Serde(serde::de::Error::custom(
3131                        "response content was None",
3132                    )))
3133                }
3134            }
3135            Err(err) => Err(err),
3136        }
3137    }
3138
3139    /// Get incident todo details.
3140    pub async fn get_incident_todo_with_http_info(
3141        &self,
3142        incident_id: String,
3143        todo_id: String,
3144    ) -> Result<
3145        datadog::ResponseContent<crate::datadogV2::model::IncidentTodoResponse>,
3146        datadog::Error<GetIncidentTodoError>,
3147    > {
3148        let local_configuration = &self.config;
3149        let operation_id = "v2.get_incident_todo";
3150        if local_configuration.is_unstable_operation_enabled(operation_id) {
3151            warn!("Using unstable operation {operation_id}");
3152        } else {
3153            let local_error = datadog::UnstableOperationDisabledError {
3154                msg: "Operation 'v2.get_incident_todo' is not enabled".to_string(),
3155            };
3156            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3157        }
3158
3159        let local_client = &self.client;
3160
3161        let local_uri_str = format!(
3162            "{}/api/v2/incidents/{incident_id}/relationships/todos/{todo_id}",
3163            local_configuration.get_operation_host(operation_id),
3164            incident_id = datadog::urlencode(incident_id),
3165            todo_id = datadog::urlencode(todo_id)
3166        );
3167        let mut local_req_builder =
3168            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3169
3170        // build headers
3171        let mut headers = HeaderMap::new();
3172        headers.insert("Accept", HeaderValue::from_static("application/json"));
3173
3174        // build user agent
3175        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3176            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3177            Err(e) => {
3178                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3179                headers.insert(
3180                    reqwest::header::USER_AGENT,
3181                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3182                )
3183            }
3184        };
3185
3186        // build auth
3187        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3188            headers.insert(
3189                "DD-API-KEY",
3190                HeaderValue::from_str(local_key.key.as_str())
3191                    .expect("failed to parse DD-API-KEY header"),
3192            );
3193        };
3194        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3195            headers.insert(
3196                "DD-APPLICATION-KEY",
3197                HeaderValue::from_str(local_key.key.as_str())
3198                    .expect("failed to parse DD-APPLICATION-KEY header"),
3199            );
3200        };
3201
3202        local_req_builder = local_req_builder.headers(headers);
3203        let local_req = local_req_builder.build()?;
3204        log::debug!("request content: {:?}", local_req.body());
3205        let local_resp = local_client.execute(local_req).await?;
3206
3207        let local_status = local_resp.status();
3208        let local_content = local_resp.text().await?;
3209        log::debug!("response content: {}", local_content);
3210
3211        if !local_status.is_client_error() && !local_status.is_server_error() {
3212            match serde_json::from_str::<crate::datadogV2::model::IncidentTodoResponse>(
3213                &local_content,
3214            ) {
3215                Ok(e) => {
3216                    return Ok(datadog::ResponseContent {
3217                        status: local_status,
3218                        content: local_content,
3219                        entity: Some(e),
3220                    })
3221                }
3222                Err(e) => return Err(datadog::Error::Serde(e)),
3223            };
3224        } else {
3225            let local_entity: Option<GetIncidentTodoError> =
3226                serde_json::from_str(&local_content).ok();
3227            let local_error = datadog::ResponseContent {
3228                status: local_status,
3229                content: local_content,
3230                entity: local_entity,
3231            };
3232            Err(datadog::Error::ResponseError(local_error))
3233        }
3234    }
3235
3236    /// Get incident type details.
3237    pub async fn get_incident_type(
3238        &self,
3239        incident_type_id: String,
3240    ) -> Result<crate::datadogV2::model::IncidentTypeResponse, datadog::Error<GetIncidentTypeError>>
3241    {
3242        match self
3243            .get_incident_type_with_http_info(incident_type_id)
3244            .await
3245        {
3246            Ok(response_content) => {
3247                if let Some(e) = response_content.entity {
3248                    Ok(e)
3249                } else {
3250                    Err(datadog::Error::Serde(serde::de::Error::custom(
3251                        "response content was None",
3252                    )))
3253                }
3254            }
3255            Err(err) => Err(err),
3256        }
3257    }
3258
3259    /// Get incident type details.
3260    pub async fn get_incident_type_with_http_info(
3261        &self,
3262        incident_type_id: String,
3263    ) -> Result<
3264        datadog::ResponseContent<crate::datadogV2::model::IncidentTypeResponse>,
3265        datadog::Error<GetIncidentTypeError>,
3266    > {
3267        let local_configuration = &self.config;
3268        let operation_id = "v2.get_incident_type";
3269        if local_configuration.is_unstable_operation_enabled(operation_id) {
3270            warn!("Using unstable operation {operation_id}");
3271        } else {
3272            let local_error = datadog::UnstableOperationDisabledError {
3273                msg: "Operation 'v2.get_incident_type' is not enabled".to_string(),
3274            };
3275            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3276        }
3277
3278        let local_client = &self.client;
3279
3280        let local_uri_str = format!(
3281            "{}/api/v2/incidents/config/types/{incident_type_id}",
3282            local_configuration.get_operation_host(operation_id),
3283            incident_type_id = datadog::urlencode(incident_type_id)
3284        );
3285        let mut local_req_builder =
3286            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3287
3288        // build headers
3289        let mut headers = HeaderMap::new();
3290        headers.insert("Accept", HeaderValue::from_static("application/json"));
3291
3292        // build user agent
3293        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3294            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3295            Err(e) => {
3296                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3297                headers.insert(
3298                    reqwest::header::USER_AGENT,
3299                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3300                )
3301            }
3302        };
3303
3304        // build auth
3305        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3306            headers.insert(
3307                "DD-API-KEY",
3308                HeaderValue::from_str(local_key.key.as_str())
3309                    .expect("failed to parse DD-API-KEY header"),
3310            );
3311        };
3312        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3313            headers.insert(
3314                "DD-APPLICATION-KEY",
3315                HeaderValue::from_str(local_key.key.as_str())
3316                    .expect("failed to parse DD-APPLICATION-KEY header"),
3317            );
3318        };
3319
3320        local_req_builder = local_req_builder.headers(headers);
3321        let local_req = local_req_builder.build()?;
3322        log::debug!("request content: {:?}", local_req.body());
3323        let local_resp = local_client.execute(local_req).await?;
3324
3325        let local_status = local_resp.status();
3326        let local_content = local_resp.text().await?;
3327        log::debug!("response content: {}", local_content);
3328
3329        if !local_status.is_client_error() && !local_status.is_server_error() {
3330            match serde_json::from_str::<crate::datadogV2::model::IncidentTypeResponse>(
3331                &local_content,
3332            ) {
3333                Ok(e) => {
3334                    return Ok(datadog::ResponseContent {
3335                        status: local_status,
3336                        content: local_content,
3337                        entity: Some(e),
3338                    })
3339                }
3340                Err(e) => return Err(datadog::Error::Serde(e)),
3341            };
3342        } else {
3343            let local_entity: Option<GetIncidentTypeError> =
3344                serde_json::from_str(&local_content).ok();
3345            let local_error = datadog::ResponseContent {
3346                status: local_status,
3347                content: local_content,
3348                entity: local_entity,
3349            };
3350            Err(datadog::Error::ResponseError(local_error))
3351        }
3352    }
3353
3354    /// Get all attachments for a given incident.
3355    pub async fn list_incident_attachments(
3356        &self,
3357        incident_id: String,
3358        params: ListIncidentAttachmentsOptionalParams,
3359    ) -> Result<
3360        crate::datadogV2::model::IncidentAttachmentsResponse,
3361        datadog::Error<ListIncidentAttachmentsError>,
3362    > {
3363        match self
3364            .list_incident_attachments_with_http_info(incident_id, params)
3365            .await
3366        {
3367            Ok(response_content) => {
3368                if let Some(e) = response_content.entity {
3369                    Ok(e)
3370                } else {
3371                    Err(datadog::Error::Serde(serde::de::Error::custom(
3372                        "response content was None",
3373                    )))
3374                }
3375            }
3376            Err(err) => Err(err),
3377        }
3378    }
3379
3380    /// Get all attachments for a given incident.
3381    pub async fn list_incident_attachments_with_http_info(
3382        &self,
3383        incident_id: String,
3384        params: ListIncidentAttachmentsOptionalParams,
3385    ) -> Result<
3386        datadog::ResponseContent<crate::datadogV2::model::IncidentAttachmentsResponse>,
3387        datadog::Error<ListIncidentAttachmentsError>,
3388    > {
3389        let local_configuration = &self.config;
3390        let operation_id = "v2.list_incident_attachments";
3391        if local_configuration.is_unstable_operation_enabled(operation_id) {
3392            warn!("Using unstable operation {operation_id}");
3393        } else {
3394            let local_error = datadog::UnstableOperationDisabledError {
3395                msg: "Operation 'v2.list_incident_attachments' is not enabled".to_string(),
3396            };
3397            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3398        }
3399
3400        // unbox and build optional parameters
3401        let include = params.include;
3402        let filter_attachment_type = params.filter_attachment_type;
3403
3404        let local_client = &self.client;
3405
3406        let local_uri_str = format!(
3407            "{}/api/v2/incidents/{incident_id}/attachments",
3408            local_configuration.get_operation_host(operation_id),
3409            incident_id = datadog::urlencode(incident_id)
3410        );
3411        let mut local_req_builder =
3412            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3413
3414        if let Some(ref local) = include {
3415            local_req_builder = local_req_builder.query(&[(
3416                "include",
3417                &local
3418                    .iter()
3419                    .map(|p| p.to_string())
3420                    .collect::<Vec<String>>()
3421                    .join(",")
3422                    .to_string(),
3423            )]);
3424        };
3425        if let Some(ref local) = filter_attachment_type {
3426            local_req_builder = local_req_builder.query(&[(
3427                "filter[attachment_type]",
3428                &local
3429                    .iter()
3430                    .map(|p| p.to_string())
3431                    .collect::<Vec<String>>()
3432                    .join(",")
3433                    .to_string(),
3434            )]);
3435        };
3436
3437        // build headers
3438        let mut headers = HeaderMap::new();
3439        headers.insert("Accept", HeaderValue::from_static("application/json"));
3440
3441        // build user agent
3442        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3443            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3444            Err(e) => {
3445                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3446                headers.insert(
3447                    reqwest::header::USER_AGENT,
3448                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3449                )
3450            }
3451        };
3452
3453        // build auth
3454        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3455            headers.insert(
3456                "DD-API-KEY",
3457                HeaderValue::from_str(local_key.key.as_str())
3458                    .expect("failed to parse DD-API-KEY header"),
3459            );
3460        };
3461        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3462            headers.insert(
3463                "DD-APPLICATION-KEY",
3464                HeaderValue::from_str(local_key.key.as_str())
3465                    .expect("failed to parse DD-APPLICATION-KEY header"),
3466            );
3467        };
3468
3469        local_req_builder = local_req_builder.headers(headers);
3470        let local_req = local_req_builder.build()?;
3471        log::debug!("request content: {:?}", local_req.body());
3472        let local_resp = local_client.execute(local_req).await?;
3473
3474        let local_status = local_resp.status();
3475        let local_content = local_resp.text().await?;
3476        log::debug!("response content: {}", local_content);
3477
3478        if !local_status.is_client_error() && !local_status.is_server_error() {
3479            match serde_json::from_str::<crate::datadogV2::model::IncidentAttachmentsResponse>(
3480                &local_content,
3481            ) {
3482                Ok(e) => {
3483                    return Ok(datadog::ResponseContent {
3484                        status: local_status,
3485                        content: local_content,
3486                        entity: Some(e),
3487                    })
3488                }
3489                Err(e) => return Err(datadog::Error::Serde(e)),
3490            };
3491        } else {
3492            let local_entity: Option<ListIncidentAttachmentsError> =
3493                serde_json::from_str(&local_content).ok();
3494            let local_error = datadog::ResponseContent {
3495                status: local_status,
3496                content: local_content,
3497                entity: local_entity,
3498            };
3499            Err(datadog::Error::ResponseError(local_error))
3500        }
3501    }
3502
3503    /// Get all impacts for an incident.
3504    pub async fn list_incident_impacts(
3505        &self,
3506        incident_id: String,
3507        params: ListIncidentImpactsOptionalParams,
3508    ) -> Result<
3509        crate::datadogV2::model::IncidentImpactsResponse,
3510        datadog::Error<ListIncidentImpactsError>,
3511    > {
3512        match self
3513            .list_incident_impacts_with_http_info(incident_id, params)
3514            .await
3515        {
3516            Ok(response_content) => {
3517                if let Some(e) = response_content.entity {
3518                    Ok(e)
3519                } else {
3520                    Err(datadog::Error::Serde(serde::de::Error::custom(
3521                        "response content was None",
3522                    )))
3523                }
3524            }
3525            Err(err) => Err(err),
3526        }
3527    }
3528
3529    /// Get all impacts for an incident.
3530    pub async fn list_incident_impacts_with_http_info(
3531        &self,
3532        incident_id: String,
3533        params: ListIncidentImpactsOptionalParams,
3534    ) -> Result<
3535        datadog::ResponseContent<crate::datadogV2::model::IncidentImpactsResponse>,
3536        datadog::Error<ListIncidentImpactsError>,
3537    > {
3538        let local_configuration = &self.config;
3539        let operation_id = "v2.list_incident_impacts";
3540        if local_configuration.is_unstable_operation_enabled(operation_id) {
3541            warn!("Using unstable operation {operation_id}");
3542        } else {
3543            let local_error = datadog::UnstableOperationDisabledError {
3544                msg: "Operation 'v2.list_incident_impacts' is not enabled".to_string(),
3545            };
3546            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3547        }
3548
3549        // unbox and build optional parameters
3550        let include = params.include;
3551
3552        let local_client = &self.client;
3553
3554        let local_uri_str = format!(
3555            "{}/api/v2/incidents/{incident_id}/impacts",
3556            local_configuration.get_operation_host(operation_id),
3557            incident_id = datadog::urlencode(incident_id)
3558        );
3559        let mut local_req_builder =
3560            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3561
3562        if let Some(ref local) = include {
3563            local_req_builder = local_req_builder.query(&[(
3564                "include",
3565                &local
3566                    .iter()
3567                    .map(|p| p.to_string())
3568                    .collect::<Vec<String>>()
3569                    .join(",")
3570                    .to_string(),
3571            )]);
3572        };
3573
3574        // build headers
3575        let mut headers = HeaderMap::new();
3576        headers.insert("Accept", HeaderValue::from_static("application/json"));
3577
3578        // build user agent
3579        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3580            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3581            Err(e) => {
3582                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3583                headers.insert(
3584                    reqwest::header::USER_AGENT,
3585                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3586                )
3587            }
3588        };
3589
3590        // build auth
3591        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3592            headers.insert(
3593                "DD-API-KEY",
3594                HeaderValue::from_str(local_key.key.as_str())
3595                    .expect("failed to parse DD-API-KEY header"),
3596            );
3597        };
3598        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3599            headers.insert(
3600                "DD-APPLICATION-KEY",
3601                HeaderValue::from_str(local_key.key.as_str())
3602                    .expect("failed to parse DD-APPLICATION-KEY header"),
3603            );
3604        };
3605
3606        local_req_builder = local_req_builder.headers(headers);
3607        let local_req = local_req_builder.build()?;
3608        log::debug!("request content: {:?}", local_req.body());
3609        let local_resp = local_client.execute(local_req).await?;
3610
3611        let local_status = local_resp.status();
3612        let local_content = local_resp.text().await?;
3613        log::debug!("response content: {}", local_content);
3614
3615        if !local_status.is_client_error() && !local_status.is_server_error() {
3616            match serde_json::from_str::<crate::datadogV2::model::IncidentImpactsResponse>(
3617                &local_content,
3618            ) {
3619                Ok(e) => {
3620                    return Ok(datadog::ResponseContent {
3621                        status: local_status,
3622                        content: local_content,
3623                        entity: Some(e),
3624                    })
3625                }
3626                Err(e) => return Err(datadog::Error::Serde(e)),
3627            };
3628        } else {
3629            let local_entity: Option<ListIncidentImpactsError> =
3630                serde_json::from_str(&local_content).ok();
3631            let local_error = datadog::ResponseContent {
3632                status: local_status,
3633                content: local_content,
3634                entity: local_entity,
3635            };
3636            Err(datadog::Error::ResponseError(local_error))
3637        }
3638    }
3639
3640    /// Get all integration metadata for an incident.
3641    pub async fn list_incident_integrations(
3642        &self,
3643        incident_id: String,
3644    ) -> Result<
3645        crate::datadogV2::model::IncidentIntegrationMetadataListResponse,
3646        datadog::Error<ListIncidentIntegrationsError>,
3647    > {
3648        match self
3649            .list_incident_integrations_with_http_info(incident_id)
3650            .await
3651        {
3652            Ok(response_content) => {
3653                if let Some(e) = response_content.entity {
3654                    Ok(e)
3655                } else {
3656                    Err(datadog::Error::Serde(serde::de::Error::custom(
3657                        "response content was None",
3658                    )))
3659                }
3660            }
3661            Err(err) => Err(err),
3662        }
3663    }
3664
3665    /// Get all integration metadata for an incident.
3666    pub async fn list_incident_integrations_with_http_info(
3667        &self,
3668        incident_id: String,
3669    ) -> Result<
3670        datadog::ResponseContent<crate::datadogV2::model::IncidentIntegrationMetadataListResponse>,
3671        datadog::Error<ListIncidentIntegrationsError>,
3672    > {
3673        let local_configuration = &self.config;
3674        let operation_id = "v2.list_incident_integrations";
3675        if local_configuration.is_unstable_operation_enabled(operation_id) {
3676            warn!("Using unstable operation {operation_id}");
3677        } else {
3678            let local_error = datadog::UnstableOperationDisabledError {
3679                msg: "Operation 'v2.list_incident_integrations' is not enabled".to_string(),
3680            };
3681            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3682        }
3683
3684        let local_client = &self.client;
3685
3686        let local_uri_str = format!(
3687            "{}/api/v2/incidents/{incident_id}/relationships/integrations",
3688            local_configuration.get_operation_host(operation_id),
3689            incident_id = datadog::urlencode(incident_id)
3690        );
3691        let mut local_req_builder =
3692            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3693
3694        // build headers
3695        let mut headers = HeaderMap::new();
3696        headers.insert("Accept", HeaderValue::from_static("application/json"));
3697
3698        // build user agent
3699        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3700            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3701            Err(e) => {
3702                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3703                headers.insert(
3704                    reqwest::header::USER_AGENT,
3705                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3706                )
3707            }
3708        };
3709
3710        // build auth
3711        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3712            headers.insert(
3713                "DD-API-KEY",
3714                HeaderValue::from_str(local_key.key.as_str())
3715                    .expect("failed to parse DD-API-KEY header"),
3716            );
3717        };
3718        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3719            headers.insert(
3720                "DD-APPLICATION-KEY",
3721                HeaderValue::from_str(local_key.key.as_str())
3722                    .expect("failed to parse DD-APPLICATION-KEY header"),
3723            );
3724        };
3725
3726        local_req_builder = local_req_builder.headers(headers);
3727        let local_req = local_req_builder.build()?;
3728        log::debug!("request content: {:?}", local_req.body());
3729        let local_resp = local_client.execute(local_req).await?;
3730
3731        let local_status = local_resp.status();
3732        let local_content = local_resp.text().await?;
3733        log::debug!("response content: {}", local_content);
3734
3735        if !local_status.is_client_error() && !local_status.is_server_error() {
3736            match serde_json::from_str::<
3737                crate::datadogV2::model::IncidentIntegrationMetadataListResponse,
3738            >(&local_content)
3739            {
3740                Ok(e) => {
3741                    return Ok(datadog::ResponseContent {
3742                        status: local_status,
3743                        content: local_content,
3744                        entity: Some(e),
3745                    })
3746                }
3747                Err(e) => return Err(datadog::Error::Serde(e)),
3748            };
3749        } else {
3750            let local_entity: Option<ListIncidentIntegrationsError> =
3751                serde_json::from_str(&local_content).ok();
3752            let local_error = datadog::ResponseContent {
3753                status: local_status,
3754                content: local_content,
3755                entity: local_entity,
3756            };
3757            Err(datadog::Error::ResponseError(local_error))
3758        }
3759    }
3760
3761    /// Lists all notification rules for the organization. Optionally filter by incident type.
3762    pub async fn list_incident_notification_rules(
3763        &self,
3764        params: ListIncidentNotificationRulesOptionalParams,
3765    ) -> Result<
3766        crate::datadogV2::model::IncidentNotificationRuleArray,
3767        datadog::Error<ListIncidentNotificationRulesError>,
3768    > {
3769        match self
3770            .list_incident_notification_rules_with_http_info(params)
3771            .await
3772        {
3773            Ok(response_content) => {
3774                if let Some(e) = response_content.entity {
3775                    Ok(e)
3776                } else {
3777                    Err(datadog::Error::Serde(serde::de::Error::custom(
3778                        "response content was None",
3779                    )))
3780                }
3781            }
3782            Err(err) => Err(err),
3783        }
3784    }
3785
3786    /// Lists all notification rules for the organization. Optionally filter by incident type.
3787    pub async fn list_incident_notification_rules_with_http_info(
3788        &self,
3789        params: ListIncidentNotificationRulesOptionalParams,
3790    ) -> Result<
3791        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationRuleArray>,
3792        datadog::Error<ListIncidentNotificationRulesError>,
3793    > {
3794        let local_configuration = &self.config;
3795        let operation_id = "v2.list_incident_notification_rules";
3796        if local_configuration.is_unstable_operation_enabled(operation_id) {
3797            warn!("Using unstable operation {operation_id}");
3798        } else {
3799            let local_error = datadog::UnstableOperationDisabledError {
3800                msg: "Operation 'v2.list_incident_notification_rules' is not enabled".to_string(),
3801            };
3802            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3803        }
3804
3805        // unbox and build optional parameters
3806        let include = params.include;
3807
3808        let local_client = &self.client;
3809
3810        let local_uri_str = format!(
3811            "{}/api/v2/incidents/config/notification-rules",
3812            local_configuration.get_operation_host(operation_id)
3813        );
3814        let mut local_req_builder =
3815            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3816
3817        if let Some(ref local_query_param) = include {
3818            local_req_builder =
3819                local_req_builder.query(&[("include", &local_query_param.to_string())]);
3820        };
3821
3822        // build headers
3823        let mut headers = HeaderMap::new();
3824        headers.insert("Accept", HeaderValue::from_static("application/json"));
3825
3826        // build user agent
3827        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3828            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3829            Err(e) => {
3830                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3831                headers.insert(
3832                    reqwest::header::USER_AGENT,
3833                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3834                )
3835            }
3836        };
3837
3838        // build auth
3839        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3840            headers.insert(
3841                "DD-API-KEY",
3842                HeaderValue::from_str(local_key.key.as_str())
3843                    .expect("failed to parse DD-API-KEY header"),
3844            );
3845        };
3846        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3847            headers.insert(
3848                "DD-APPLICATION-KEY",
3849                HeaderValue::from_str(local_key.key.as_str())
3850                    .expect("failed to parse DD-APPLICATION-KEY header"),
3851            );
3852        };
3853
3854        local_req_builder = local_req_builder.headers(headers);
3855        let local_req = local_req_builder.build()?;
3856        log::debug!("request content: {:?}", local_req.body());
3857        let local_resp = local_client.execute(local_req).await?;
3858
3859        let local_status = local_resp.status();
3860        let local_content = local_resp.text().await?;
3861        log::debug!("response content: {}", local_content);
3862
3863        if !local_status.is_client_error() && !local_status.is_server_error() {
3864            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationRuleArray>(
3865                &local_content,
3866            ) {
3867                Ok(e) => {
3868                    return Ok(datadog::ResponseContent {
3869                        status: local_status,
3870                        content: local_content,
3871                        entity: Some(e),
3872                    })
3873                }
3874                Err(e) => return Err(datadog::Error::Serde(e)),
3875            };
3876        } else {
3877            let local_entity: Option<ListIncidentNotificationRulesError> =
3878                serde_json::from_str(&local_content).ok();
3879            let local_error = datadog::ResponseContent {
3880                status: local_status,
3881                content: local_content,
3882                entity: local_entity,
3883            };
3884            Err(datadog::Error::ResponseError(local_error))
3885        }
3886    }
3887
3888    /// Lists all notification templates. Optionally filter by incident type.
3889    pub async fn list_incident_notification_templates(
3890        &self,
3891        params: ListIncidentNotificationTemplatesOptionalParams,
3892    ) -> Result<
3893        crate::datadogV2::model::IncidentNotificationTemplateArray,
3894        datadog::Error<ListIncidentNotificationTemplatesError>,
3895    > {
3896        match self
3897            .list_incident_notification_templates_with_http_info(params)
3898            .await
3899        {
3900            Ok(response_content) => {
3901                if let Some(e) = response_content.entity {
3902                    Ok(e)
3903                } else {
3904                    Err(datadog::Error::Serde(serde::de::Error::custom(
3905                        "response content was None",
3906                    )))
3907                }
3908            }
3909            Err(err) => Err(err),
3910        }
3911    }
3912
3913    /// Lists all notification templates. Optionally filter by incident type.
3914    pub async fn list_incident_notification_templates_with_http_info(
3915        &self,
3916        params: ListIncidentNotificationTemplatesOptionalParams,
3917    ) -> Result<
3918        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationTemplateArray>,
3919        datadog::Error<ListIncidentNotificationTemplatesError>,
3920    > {
3921        let local_configuration = &self.config;
3922        let operation_id = "v2.list_incident_notification_templates";
3923        if local_configuration.is_unstable_operation_enabled(operation_id) {
3924            warn!("Using unstable operation {operation_id}");
3925        } else {
3926            let local_error = datadog::UnstableOperationDisabledError {
3927                msg: "Operation 'v2.list_incident_notification_templates' is not enabled"
3928                    .to_string(),
3929            };
3930            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3931        }
3932
3933        // unbox and build optional parameters
3934        let filter_incident_type = params.filter_incident_type;
3935        let include = params.include;
3936
3937        let local_client = &self.client;
3938
3939        let local_uri_str = format!(
3940            "{}/api/v2/incidents/config/notification-templates",
3941            local_configuration.get_operation_host(operation_id)
3942        );
3943        let mut local_req_builder =
3944            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3945
3946        if let Some(ref local_query_param) = filter_incident_type {
3947            local_req_builder = local_req_builder
3948                .query(&[("filter[incident-type]", &local_query_param.to_string())]);
3949        };
3950        if let Some(ref local_query_param) = include {
3951            local_req_builder =
3952                local_req_builder.query(&[("include", &local_query_param.to_string())]);
3953        };
3954
3955        // build headers
3956        let mut headers = HeaderMap::new();
3957        headers.insert("Accept", HeaderValue::from_static("application/json"));
3958
3959        // build user agent
3960        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3961            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3962            Err(e) => {
3963                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3964                headers.insert(
3965                    reqwest::header::USER_AGENT,
3966                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3967                )
3968            }
3969        };
3970
3971        // build auth
3972        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3973            headers.insert(
3974                "DD-API-KEY",
3975                HeaderValue::from_str(local_key.key.as_str())
3976                    .expect("failed to parse DD-API-KEY header"),
3977            );
3978        };
3979        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3980            headers.insert(
3981                "DD-APPLICATION-KEY",
3982                HeaderValue::from_str(local_key.key.as_str())
3983                    .expect("failed to parse DD-APPLICATION-KEY header"),
3984            );
3985        };
3986
3987        local_req_builder = local_req_builder.headers(headers);
3988        let local_req = local_req_builder.build()?;
3989        log::debug!("request content: {:?}", local_req.body());
3990        let local_resp = local_client.execute(local_req).await?;
3991
3992        let local_status = local_resp.status();
3993        let local_content = local_resp.text().await?;
3994        log::debug!("response content: {}", local_content);
3995
3996        if !local_status.is_client_error() && !local_status.is_server_error() {
3997            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationTemplateArray>(
3998                &local_content,
3999            ) {
4000                Ok(e) => {
4001                    return Ok(datadog::ResponseContent {
4002                        status: local_status,
4003                        content: local_content,
4004                        entity: Some(e),
4005                    })
4006                }
4007                Err(e) => return Err(datadog::Error::Serde(e)),
4008            };
4009        } else {
4010            let local_entity: Option<ListIncidentNotificationTemplatesError> =
4011                serde_json::from_str(&local_content).ok();
4012            let local_error = datadog::ResponseContent {
4013                status: local_status,
4014                content: local_content,
4015                entity: local_entity,
4016            };
4017            Err(datadog::Error::ResponseError(local_error))
4018        }
4019    }
4020
4021    /// Get all todos for an incident.
4022    pub async fn list_incident_todos(
4023        &self,
4024        incident_id: String,
4025    ) -> Result<
4026        crate::datadogV2::model::IncidentTodoListResponse,
4027        datadog::Error<ListIncidentTodosError>,
4028    > {
4029        match self.list_incident_todos_with_http_info(incident_id).await {
4030            Ok(response_content) => {
4031                if let Some(e) = response_content.entity {
4032                    Ok(e)
4033                } else {
4034                    Err(datadog::Error::Serde(serde::de::Error::custom(
4035                        "response content was None",
4036                    )))
4037                }
4038            }
4039            Err(err) => Err(err),
4040        }
4041    }
4042
4043    /// Get all todos for an incident.
4044    pub async fn list_incident_todos_with_http_info(
4045        &self,
4046        incident_id: String,
4047    ) -> Result<
4048        datadog::ResponseContent<crate::datadogV2::model::IncidentTodoListResponse>,
4049        datadog::Error<ListIncidentTodosError>,
4050    > {
4051        let local_configuration = &self.config;
4052        let operation_id = "v2.list_incident_todos";
4053        if local_configuration.is_unstable_operation_enabled(operation_id) {
4054            warn!("Using unstable operation {operation_id}");
4055        } else {
4056            let local_error = datadog::UnstableOperationDisabledError {
4057                msg: "Operation 'v2.list_incident_todos' is not enabled".to_string(),
4058            };
4059            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4060        }
4061
4062        let local_client = &self.client;
4063
4064        let local_uri_str = format!(
4065            "{}/api/v2/incidents/{incident_id}/relationships/todos",
4066            local_configuration.get_operation_host(operation_id),
4067            incident_id = datadog::urlencode(incident_id)
4068        );
4069        let mut local_req_builder =
4070            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4071
4072        // build headers
4073        let mut headers = HeaderMap::new();
4074        headers.insert("Accept", HeaderValue::from_static("application/json"));
4075
4076        // build user agent
4077        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4078            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4079            Err(e) => {
4080                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4081                headers.insert(
4082                    reqwest::header::USER_AGENT,
4083                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4084                )
4085            }
4086        };
4087
4088        // build auth
4089        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4090            headers.insert(
4091                "DD-API-KEY",
4092                HeaderValue::from_str(local_key.key.as_str())
4093                    .expect("failed to parse DD-API-KEY header"),
4094            );
4095        };
4096        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4097            headers.insert(
4098                "DD-APPLICATION-KEY",
4099                HeaderValue::from_str(local_key.key.as_str())
4100                    .expect("failed to parse DD-APPLICATION-KEY header"),
4101            );
4102        };
4103
4104        local_req_builder = local_req_builder.headers(headers);
4105        let local_req = local_req_builder.build()?;
4106        log::debug!("request content: {:?}", local_req.body());
4107        let local_resp = local_client.execute(local_req).await?;
4108
4109        let local_status = local_resp.status();
4110        let local_content = local_resp.text().await?;
4111        log::debug!("response content: {}", local_content);
4112
4113        if !local_status.is_client_error() && !local_status.is_server_error() {
4114            match serde_json::from_str::<crate::datadogV2::model::IncidentTodoListResponse>(
4115                &local_content,
4116            ) {
4117                Ok(e) => {
4118                    return Ok(datadog::ResponseContent {
4119                        status: local_status,
4120                        content: local_content,
4121                        entity: Some(e),
4122                    })
4123                }
4124                Err(e) => return Err(datadog::Error::Serde(e)),
4125            };
4126        } else {
4127            let local_entity: Option<ListIncidentTodosError> =
4128                serde_json::from_str(&local_content).ok();
4129            let local_error = datadog::ResponseContent {
4130                status: local_status,
4131                content: local_content,
4132                entity: local_entity,
4133            };
4134            Err(datadog::Error::ResponseError(local_error))
4135        }
4136    }
4137
4138    /// Get all incident types.
4139    pub async fn list_incident_types(
4140        &self,
4141        params: ListIncidentTypesOptionalParams,
4142    ) -> Result<
4143        crate::datadogV2::model::IncidentTypeListResponse,
4144        datadog::Error<ListIncidentTypesError>,
4145    > {
4146        match self.list_incident_types_with_http_info(params).await {
4147            Ok(response_content) => {
4148                if let Some(e) = response_content.entity {
4149                    Ok(e)
4150                } else {
4151                    Err(datadog::Error::Serde(serde::de::Error::custom(
4152                        "response content was None",
4153                    )))
4154                }
4155            }
4156            Err(err) => Err(err),
4157        }
4158    }
4159
4160    /// Get all incident types.
4161    pub async fn list_incident_types_with_http_info(
4162        &self,
4163        params: ListIncidentTypesOptionalParams,
4164    ) -> Result<
4165        datadog::ResponseContent<crate::datadogV2::model::IncidentTypeListResponse>,
4166        datadog::Error<ListIncidentTypesError>,
4167    > {
4168        let local_configuration = &self.config;
4169        let operation_id = "v2.list_incident_types";
4170        if local_configuration.is_unstable_operation_enabled(operation_id) {
4171            warn!("Using unstable operation {operation_id}");
4172        } else {
4173            let local_error = datadog::UnstableOperationDisabledError {
4174                msg: "Operation 'v2.list_incident_types' is not enabled".to_string(),
4175            };
4176            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4177        }
4178
4179        // unbox and build optional parameters
4180        let include_deleted = params.include_deleted;
4181
4182        let local_client = &self.client;
4183
4184        let local_uri_str = format!(
4185            "{}/api/v2/incidents/config/types",
4186            local_configuration.get_operation_host(operation_id)
4187        );
4188        let mut local_req_builder =
4189            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4190
4191        if let Some(ref local_query_param) = include_deleted {
4192            local_req_builder =
4193                local_req_builder.query(&[("include_deleted", &local_query_param.to_string())]);
4194        };
4195
4196        // build headers
4197        let mut headers = HeaderMap::new();
4198        headers.insert("Accept", HeaderValue::from_static("application/json"));
4199
4200        // build user agent
4201        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4202            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4203            Err(e) => {
4204                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4205                headers.insert(
4206                    reqwest::header::USER_AGENT,
4207                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4208                )
4209            }
4210        };
4211
4212        // build auth
4213        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4214            headers.insert(
4215                "DD-API-KEY",
4216                HeaderValue::from_str(local_key.key.as_str())
4217                    .expect("failed to parse DD-API-KEY header"),
4218            );
4219        };
4220        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4221            headers.insert(
4222                "DD-APPLICATION-KEY",
4223                HeaderValue::from_str(local_key.key.as_str())
4224                    .expect("failed to parse DD-APPLICATION-KEY header"),
4225            );
4226        };
4227
4228        local_req_builder = local_req_builder.headers(headers);
4229        let local_req = local_req_builder.build()?;
4230        log::debug!("request content: {:?}", local_req.body());
4231        let local_resp = local_client.execute(local_req).await?;
4232
4233        let local_status = local_resp.status();
4234        let local_content = local_resp.text().await?;
4235        log::debug!("response content: {}", local_content);
4236
4237        if !local_status.is_client_error() && !local_status.is_server_error() {
4238            match serde_json::from_str::<crate::datadogV2::model::IncidentTypeListResponse>(
4239                &local_content,
4240            ) {
4241                Ok(e) => {
4242                    return Ok(datadog::ResponseContent {
4243                        status: local_status,
4244                        content: local_content,
4245                        entity: Some(e),
4246                    })
4247                }
4248                Err(e) => return Err(datadog::Error::Serde(e)),
4249            };
4250        } else {
4251            let local_entity: Option<ListIncidentTypesError> =
4252                serde_json::from_str(&local_content).ok();
4253            let local_error = datadog::ResponseContent {
4254                status: local_status,
4255                content: local_content,
4256                entity: local_entity,
4257            };
4258            Err(datadog::Error::ResponseError(local_error))
4259        }
4260    }
4261
4262    /// Get all incidents for the user's organization.
4263    pub async fn list_incidents(
4264        &self,
4265        params: ListIncidentsOptionalParams,
4266    ) -> Result<crate::datadogV2::model::IncidentsResponse, datadog::Error<ListIncidentsError>>
4267    {
4268        match self.list_incidents_with_http_info(params).await {
4269            Ok(response_content) => {
4270                if let Some(e) = response_content.entity {
4271                    Ok(e)
4272                } else {
4273                    Err(datadog::Error::Serde(serde::de::Error::custom(
4274                        "response content was None",
4275                    )))
4276                }
4277            }
4278            Err(err) => Err(err),
4279        }
4280    }
4281
4282    pub fn list_incidents_with_pagination(
4283        &self,
4284        mut params: ListIncidentsOptionalParams,
4285    ) -> impl Stream<
4286        Item = Result<
4287            crate::datadogV2::model::IncidentResponseData,
4288            datadog::Error<ListIncidentsError>,
4289        >,
4290    > + '_ {
4291        try_stream! {
4292            let mut page_size: i64 = 10;
4293            if params.page_size.is_none() {
4294                params.page_size = Some(page_size);
4295            } else {
4296                page_size = params.page_size.unwrap().clone();
4297            }
4298            loop {
4299                let resp = self.list_incidents(params.clone()).await?;
4300
4301                let r = resp.data;
4302                let count = r.len();
4303                for team in r {
4304                    yield team;
4305                }
4306
4307                if count < page_size as usize {
4308                    break;
4309                }
4310                if params.page_offset.is_none() {
4311                    params.page_offset = Some(page_size.clone());
4312                } else {
4313                    params.page_offset = Some(params.page_offset.unwrap() + page_size.clone());
4314                }
4315            }
4316        }
4317    }
4318
4319    /// Get all incidents for the user's organization.
4320    pub async fn list_incidents_with_http_info(
4321        &self,
4322        params: ListIncidentsOptionalParams,
4323    ) -> Result<
4324        datadog::ResponseContent<crate::datadogV2::model::IncidentsResponse>,
4325        datadog::Error<ListIncidentsError>,
4326    > {
4327        let local_configuration = &self.config;
4328        let operation_id = "v2.list_incidents";
4329        if local_configuration.is_unstable_operation_enabled(operation_id) {
4330            warn!("Using unstable operation {operation_id}");
4331        } else {
4332            let local_error = datadog::UnstableOperationDisabledError {
4333                msg: "Operation 'v2.list_incidents' is not enabled".to_string(),
4334            };
4335            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4336        }
4337
4338        // unbox and build optional parameters
4339        let include = params.include;
4340        let page_size = params.page_size;
4341        let page_offset = params.page_offset;
4342
4343        let local_client = &self.client;
4344
4345        let local_uri_str = format!(
4346            "{}/api/v2/incidents",
4347            local_configuration.get_operation_host(operation_id)
4348        );
4349        let mut local_req_builder =
4350            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4351
4352        if let Some(ref local) = include {
4353            local_req_builder = local_req_builder.query(&[(
4354                "include",
4355                &local
4356                    .iter()
4357                    .map(|p| p.to_string())
4358                    .collect::<Vec<String>>()
4359                    .join(",")
4360                    .to_string(),
4361            )]);
4362        };
4363        if let Some(ref local_query_param) = page_size {
4364            local_req_builder =
4365                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
4366        };
4367        if let Some(ref local_query_param) = page_offset {
4368            local_req_builder =
4369                local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]);
4370        };
4371
4372        // build headers
4373        let mut headers = HeaderMap::new();
4374        headers.insert("Accept", HeaderValue::from_static("application/json"));
4375
4376        // build user agent
4377        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4378            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4379            Err(e) => {
4380                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4381                headers.insert(
4382                    reqwest::header::USER_AGENT,
4383                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4384                )
4385            }
4386        };
4387
4388        // build auth
4389        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4390            headers.insert(
4391                "DD-API-KEY",
4392                HeaderValue::from_str(local_key.key.as_str())
4393                    .expect("failed to parse DD-API-KEY header"),
4394            );
4395        };
4396        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4397            headers.insert(
4398                "DD-APPLICATION-KEY",
4399                HeaderValue::from_str(local_key.key.as_str())
4400                    .expect("failed to parse DD-APPLICATION-KEY header"),
4401            );
4402        };
4403
4404        local_req_builder = local_req_builder.headers(headers);
4405        let local_req = local_req_builder.build()?;
4406        log::debug!("request content: {:?}", local_req.body());
4407        let local_resp = local_client.execute(local_req).await?;
4408
4409        let local_status = local_resp.status();
4410        let local_content = local_resp.text().await?;
4411        log::debug!("response content: {}", local_content);
4412
4413        if !local_status.is_client_error() && !local_status.is_server_error() {
4414            match serde_json::from_str::<crate::datadogV2::model::IncidentsResponse>(&local_content)
4415            {
4416                Ok(e) => {
4417                    return Ok(datadog::ResponseContent {
4418                        status: local_status,
4419                        content: local_content,
4420                        entity: Some(e),
4421                    })
4422                }
4423                Err(e) => return Err(datadog::Error::Serde(e)),
4424            };
4425        } else {
4426            let local_entity: Option<ListIncidentsError> =
4427                serde_json::from_str(&local_content).ok();
4428            let local_error = datadog::ResponseContent {
4429                status: local_status,
4430                content: local_content,
4431                entity: local_entity,
4432            };
4433            Err(datadog::Error::ResponseError(local_error))
4434        }
4435    }
4436
4437    /// Search for incidents matching a certain query.
4438    pub async fn search_incidents(
4439        &self,
4440        query: String,
4441        params: SearchIncidentsOptionalParams,
4442    ) -> Result<crate::datadogV2::model::IncidentSearchResponse, datadog::Error<SearchIncidentsError>>
4443    {
4444        match self.search_incidents_with_http_info(query, params).await {
4445            Ok(response_content) => {
4446                if let Some(e) = response_content.entity {
4447                    Ok(e)
4448                } else {
4449                    Err(datadog::Error::Serde(serde::de::Error::custom(
4450                        "response content was None",
4451                    )))
4452                }
4453            }
4454            Err(err) => Err(err),
4455        }
4456    }
4457
4458    pub fn search_incidents_with_pagination(
4459        &self,
4460        query: String,
4461        mut params: SearchIncidentsOptionalParams,
4462    ) -> impl Stream<
4463        Item = Result<
4464            crate::datadogV2::model::IncidentSearchResponseIncidentsData,
4465            datadog::Error<SearchIncidentsError>,
4466        >,
4467    > + '_ {
4468        try_stream! {
4469            let mut page_size: i64 = 10;
4470            if params.page_size.is_none() {
4471                params.page_size = Some(page_size);
4472            } else {
4473                page_size = params.page_size.unwrap().clone();
4474            }
4475            loop {
4476                let resp = self.search_incidents( query.clone(),params.clone()).await?;
4477                let Some(attributes) = resp.data.attributes else { break };
4478
4479                let r = attributes.incidents;
4480                let count = r.len();
4481                for team in r {
4482                    yield team;
4483                }
4484
4485                if count < page_size as usize {
4486                    break;
4487                }
4488                if params.page_offset.is_none() {
4489                    params.page_offset = Some(page_size.clone());
4490                } else {
4491                    params.page_offset = Some(params.page_offset.unwrap() + page_size.clone());
4492                }
4493            }
4494        }
4495    }
4496
4497    /// Search for incidents matching a certain query.
4498    pub async fn search_incidents_with_http_info(
4499        &self,
4500        query: String,
4501        params: SearchIncidentsOptionalParams,
4502    ) -> Result<
4503        datadog::ResponseContent<crate::datadogV2::model::IncidentSearchResponse>,
4504        datadog::Error<SearchIncidentsError>,
4505    > {
4506        let local_configuration = &self.config;
4507        let operation_id = "v2.search_incidents";
4508        if local_configuration.is_unstable_operation_enabled(operation_id) {
4509            warn!("Using unstable operation {operation_id}");
4510        } else {
4511            let local_error = datadog::UnstableOperationDisabledError {
4512                msg: "Operation 'v2.search_incidents' is not enabled".to_string(),
4513            };
4514            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4515        }
4516
4517        // unbox and build optional parameters
4518        let include = params.include;
4519        let sort = params.sort;
4520        let page_size = params.page_size;
4521        let page_offset = params.page_offset;
4522
4523        let local_client = &self.client;
4524
4525        let local_uri_str = format!(
4526            "{}/api/v2/incidents/search",
4527            local_configuration.get_operation_host(operation_id)
4528        );
4529        let mut local_req_builder =
4530            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4531
4532        local_req_builder = local_req_builder.query(&[("query", &query.to_string())]);
4533        if let Some(ref local_query_param) = include {
4534            local_req_builder =
4535                local_req_builder.query(&[("include", &local_query_param.to_string())]);
4536        };
4537        if let Some(ref local_query_param) = sort {
4538            local_req_builder =
4539                local_req_builder.query(&[("sort", &local_query_param.to_string())]);
4540        };
4541        if let Some(ref local_query_param) = page_size {
4542            local_req_builder =
4543                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
4544        };
4545        if let Some(ref local_query_param) = page_offset {
4546            local_req_builder =
4547                local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]);
4548        };
4549
4550        // build headers
4551        let mut headers = HeaderMap::new();
4552        headers.insert("Accept", HeaderValue::from_static("application/json"));
4553
4554        // build user agent
4555        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4556            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4557            Err(e) => {
4558                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4559                headers.insert(
4560                    reqwest::header::USER_AGENT,
4561                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4562                )
4563            }
4564        };
4565
4566        // build auth
4567        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4568            headers.insert(
4569                "DD-API-KEY",
4570                HeaderValue::from_str(local_key.key.as_str())
4571                    .expect("failed to parse DD-API-KEY header"),
4572            );
4573        };
4574        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4575            headers.insert(
4576                "DD-APPLICATION-KEY",
4577                HeaderValue::from_str(local_key.key.as_str())
4578                    .expect("failed to parse DD-APPLICATION-KEY header"),
4579            );
4580        };
4581
4582        local_req_builder = local_req_builder.headers(headers);
4583        let local_req = local_req_builder.build()?;
4584        log::debug!("request content: {:?}", local_req.body());
4585        let local_resp = local_client.execute(local_req).await?;
4586
4587        let local_status = local_resp.status();
4588        let local_content = local_resp.text().await?;
4589        log::debug!("response content: {}", local_content);
4590
4591        if !local_status.is_client_error() && !local_status.is_server_error() {
4592            match serde_json::from_str::<crate::datadogV2::model::IncidentSearchResponse>(
4593                &local_content,
4594            ) {
4595                Ok(e) => {
4596                    return Ok(datadog::ResponseContent {
4597                        status: local_status,
4598                        content: local_content,
4599                        entity: Some(e),
4600                    })
4601                }
4602                Err(e) => return Err(datadog::Error::Serde(e)),
4603            };
4604        } else {
4605            let local_entity: Option<SearchIncidentsError> =
4606                serde_json::from_str(&local_content).ok();
4607            let local_error = datadog::ResponseContent {
4608                status: local_status,
4609                content: local_content,
4610                entity: local_entity,
4611            };
4612            Err(datadog::Error::ResponseError(local_error))
4613        }
4614    }
4615
4616    /// Updates an incident. Provide only the attributes that should be updated as this request is a partial update.
4617    pub async fn update_incident(
4618        &self,
4619        incident_id: String,
4620        body: crate::datadogV2::model::IncidentUpdateRequest,
4621        params: UpdateIncidentOptionalParams,
4622    ) -> Result<crate::datadogV2::model::IncidentResponse, datadog::Error<UpdateIncidentError>>
4623    {
4624        match self
4625            .update_incident_with_http_info(incident_id, body, params)
4626            .await
4627        {
4628            Ok(response_content) => {
4629                if let Some(e) = response_content.entity {
4630                    Ok(e)
4631                } else {
4632                    Err(datadog::Error::Serde(serde::de::Error::custom(
4633                        "response content was None",
4634                    )))
4635                }
4636            }
4637            Err(err) => Err(err),
4638        }
4639    }
4640
4641    /// Updates an incident. Provide only the attributes that should be updated as this request is a partial update.
4642    pub async fn update_incident_with_http_info(
4643        &self,
4644        incident_id: String,
4645        body: crate::datadogV2::model::IncidentUpdateRequest,
4646        params: UpdateIncidentOptionalParams,
4647    ) -> Result<
4648        datadog::ResponseContent<crate::datadogV2::model::IncidentResponse>,
4649        datadog::Error<UpdateIncidentError>,
4650    > {
4651        let local_configuration = &self.config;
4652        let operation_id = "v2.update_incident";
4653        if local_configuration.is_unstable_operation_enabled(operation_id) {
4654            warn!("Using unstable operation {operation_id}");
4655        } else {
4656            let local_error = datadog::UnstableOperationDisabledError {
4657                msg: "Operation 'v2.update_incident' is not enabled".to_string(),
4658            };
4659            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4660        }
4661
4662        // unbox and build optional parameters
4663        let include = params.include;
4664
4665        let local_client = &self.client;
4666
4667        let local_uri_str = format!(
4668            "{}/api/v2/incidents/{incident_id}",
4669            local_configuration.get_operation_host(operation_id),
4670            incident_id = datadog::urlencode(incident_id)
4671        );
4672        let mut local_req_builder =
4673            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4674
4675        if let Some(ref local) = include {
4676            local_req_builder = local_req_builder.query(&[(
4677                "include",
4678                &local
4679                    .iter()
4680                    .map(|p| p.to_string())
4681                    .collect::<Vec<String>>()
4682                    .join(",")
4683                    .to_string(),
4684            )]);
4685        };
4686
4687        // build headers
4688        let mut headers = HeaderMap::new();
4689        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4690        headers.insert("Accept", HeaderValue::from_static("application/json"));
4691
4692        // build user agent
4693        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4694            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4695            Err(e) => {
4696                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4697                headers.insert(
4698                    reqwest::header::USER_AGENT,
4699                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4700                )
4701            }
4702        };
4703
4704        // build auth
4705        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4706            headers.insert(
4707                "DD-API-KEY",
4708                HeaderValue::from_str(local_key.key.as_str())
4709                    .expect("failed to parse DD-API-KEY header"),
4710            );
4711        };
4712        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4713            headers.insert(
4714                "DD-APPLICATION-KEY",
4715                HeaderValue::from_str(local_key.key.as_str())
4716                    .expect("failed to parse DD-APPLICATION-KEY header"),
4717            );
4718        };
4719
4720        // build body parameters
4721        let output = Vec::new();
4722        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4723        if body.serialize(&mut ser).is_ok() {
4724            if let Some(content_encoding) = headers.get("Content-Encoding") {
4725                match content_encoding.to_str().unwrap_or_default() {
4726                    "gzip" => {
4727                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4728                        let _ = enc.write_all(ser.into_inner().as_slice());
4729                        match enc.finish() {
4730                            Ok(buf) => {
4731                                local_req_builder = local_req_builder.body(buf);
4732                            }
4733                            Err(e) => return Err(datadog::Error::Io(e)),
4734                        }
4735                    }
4736                    "deflate" => {
4737                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4738                        let _ = enc.write_all(ser.into_inner().as_slice());
4739                        match enc.finish() {
4740                            Ok(buf) => {
4741                                local_req_builder = local_req_builder.body(buf);
4742                            }
4743                            Err(e) => return Err(datadog::Error::Io(e)),
4744                        }
4745                    }
4746                    "zstd1" => {
4747                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4748                        let _ = enc.write_all(ser.into_inner().as_slice());
4749                        match enc.finish() {
4750                            Ok(buf) => {
4751                                local_req_builder = local_req_builder.body(buf);
4752                            }
4753                            Err(e) => return Err(datadog::Error::Io(e)),
4754                        }
4755                    }
4756                    _ => {
4757                        local_req_builder = local_req_builder.body(ser.into_inner());
4758                    }
4759                }
4760            } else {
4761                local_req_builder = local_req_builder.body(ser.into_inner());
4762            }
4763        }
4764
4765        local_req_builder = local_req_builder.headers(headers);
4766        let local_req = local_req_builder.build()?;
4767        log::debug!("request content: {:?}", local_req.body());
4768        let local_resp = local_client.execute(local_req).await?;
4769
4770        let local_status = local_resp.status();
4771        let local_content = local_resp.text().await?;
4772        log::debug!("response content: {}", local_content);
4773
4774        if !local_status.is_client_error() && !local_status.is_server_error() {
4775            match serde_json::from_str::<crate::datadogV2::model::IncidentResponse>(&local_content)
4776            {
4777                Ok(e) => {
4778                    return Ok(datadog::ResponseContent {
4779                        status: local_status,
4780                        content: local_content,
4781                        entity: Some(e),
4782                    })
4783                }
4784                Err(e) => return Err(datadog::Error::Serde(e)),
4785            };
4786        } else {
4787            let local_entity: Option<UpdateIncidentError> =
4788                serde_json::from_str(&local_content).ok();
4789            let local_error = datadog::ResponseContent {
4790                status: local_status,
4791                content: local_content,
4792                entity: local_entity,
4793            };
4794            Err(datadog::Error::ResponseError(local_error))
4795        }
4796    }
4797
4798    /// The bulk update endpoint for creating, updating, and deleting attachments for a given incident.
4799    pub async fn update_incident_attachments(
4800        &self,
4801        incident_id: String,
4802        body: crate::datadogV2::model::IncidentAttachmentUpdateRequest,
4803        params: UpdateIncidentAttachmentsOptionalParams,
4804    ) -> Result<
4805        crate::datadogV2::model::IncidentAttachmentUpdateResponse,
4806        datadog::Error<UpdateIncidentAttachmentsError>,
4807    > {
4808        match self
4809            .update_incident_attachments_with_http_info(incident_id, body, params)
4810            .await
4811        {
4812            Ok(response_content) => {
4813                if let Some(e) = response_content.entity {
4814                    Ok(e)
4815                } else {
4816                    Err(datadog::Error::Serde(serde::de::Error::custom(
4817                        "response content was None",
4818                    )))
4819                }
4820            }
4821            Err(err) => Err(err),
4822        }
4823    }
4824
4825    /// The bulk update endpoint for creating, updating, and deleting attachments for a given incident.
4826    pub async fn update_incident_attachments_with_http_info(
4827        &self,
4828        incident_id: String,
4829        body: crate::datadogV2::model::IncidentAttachmentUpdateRequest,
4830        params: UpdateIncidentAttachmentsOptionalParams,
4831    ) -> Result<
4832        datadog::ResponseContent<crate::datadogV2::model::IncidentAttachmentUpdateResponse>,
4833        datadog::Error<UpdateIncidentAttachmentsError>,
4834    > {
4835        let local_configuration = &self.config;
4836        let operation_id = "v2.update_incident_attachments";
4837        if local_configuration.is_unstable_operation_enabled(operation_id) {
4838            warn!("Using unstable operation {operation_id}");
4839        } else {
4840            let local_error = datadog::UnstableOperationDisabledError {
4841                msg: "Operation 'v2.update_incident_attachments' is not enabled".to_string(),
4842            };
4843            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4844        }
4845
4846        // unbox and build optional parameters
4847        let include = params.include;
4848
4849        let local_client = &self.client;
4850
4851        let local_uri_str = format!(
4852            "{}/api/v2/incidents/{incident_id}/attachments",
4853            local_configuration.get_operation_host(operation_id),
4854            incident_id = datadog::urlencode(incident_id)
4855        );
4856        let mut local_req_builder =
4857            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4858
4859        if let Some(ref local) = include {
4860            local_req_builder = local_req_builder.query(&[(
4861                "include",
4862                &local
4863                    .iter()
4864                    .map(|p| p.to_string())
4865                    .collect::<Vec<String>>()
4866                    .join(",")
4867                    .to_string(),
4868            )]);
4869        };
4870
4871        // build headers
4872        let mut headers = HeaderMap::new();
4873        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4874        headers.insert("Accept", HeaderValue::from_static("application/json"));
4875
4876        // build user agent
4877        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4878            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4879            Err(e) => {
4880                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4881                headers.insert(
4882                    reqwest::header::USER_AGENT,
4883                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4884                )
4885            }
4886        };
4887
4888        // build auth
4889        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4890            headers.insert(
4891                "DD-API-KEY",
4892                HeaderValue::from_str(local_key.key.as_str())
4893                    .expect("failed to parse DD-API-KEY header"),
4894            );
4895        };
4896        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4897            headers.insert(
4898                "DD-APPLICATION-KEY",
4899                HeaderValue::from_str(local_key.key.as_str())
4900                    .expect("failed to parse DD-APPLICATION-KEY header"),
4901            );
4902        };
4903
4904        // build body parameters
4905        let output = Vec::new();
4906        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4907        if body.serialize(&mut ser).is_ok() {
4908            if let Some(content_encoding) = headers.get("Content-Encoding") {
4909                match content_encoding.to_str().unwrap_or_default() {
4910                    "gzip" => {
4911                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4912                        let _ = enc.write_all(ser.into_inner().as_slice());
4913                        match enc.finish() {
4914                            Ok(buf) => {
4915                                local_req_builder = local_req_builder.body(buf);
4916                            }
4917                            Err(e) => return Err(datadog::Error::Io(e)),
4918                        }
4919                    }
4920                    "deflate" => {
4921                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4922                        let _ = enc.write_all(ser.into_inner().as_slice());
4923                        match enc.finish() {
4924                            Ok(buf) => {
4925                                local_req_builder = local_req_builder.body(buf);
4926                            }
4927                            Err(e) => return Err(datadog::Error::Io(e)),
4928                        }
4929                    }
4930                    "zstd1" => {
4931                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4932                        let _ = enc.write_all(ser.into_inner().as_slice());
4933                        match enc.finish() {
4934                            Ok(buf) => {
4935                                local_req_builder = local_req_builder.body(buf);
4936                            }
4937                            Err(e) => return Err(datadog::Error::Io(e)),
4938                        }
4939                    }
4940                    _ => {
4941                        local_req_builder = local_req_builder.body(ser.into_inner());
4942                    }
4943                }
4944            } else {
4945                local_req_builder = local_req_builder.body(ser.into_inner());
4946            }
4947        }
4948
4949        local_req_builder = local_req_builder.headers(headers);
4950        let local_req = local_req_builder.build()?;
4951        log::debug!("request content: {:?}", local_req.body());
4952        let local_resp = local_client.execute(local_req).await?;
4953
4954        let local_status = local_resp.status();
4955        let local_content = local_resp.text().await?;
4956        log::debug!("response content: {}", local_content);
4957
4958        if !local_status.is_client_error() && !local_status.is_server_error() {
4959            match serde_json::from_str::<crate::datadogV2::model::IncidentAttachmentUpdateResponse>(
4960                &local_content,
4961            ) {
4962                Ok(e) => {
4963                    return Ok(datadog::ResponseContent {
4964                        status: local_status,
4965                        content: local_content,
4966                        entity: Some(e),
4967                    })
4968                }
4969                Err(e) => return Err(datadog::Error::Serde(e)),
4970            };
4971        } else {
4972            let local_entity: Option<UpdateIncidentAttachmentsError> =
4973                serde_json::from_str(&local_content).ok();
4974            let local_error = datadog::ResponseContent {
4975                status: local_status,
4976                content: local_content,
4977                entity: local_entity,
4978            };
4979            Err(datadog::Error::ResponseError(local_error))
4980        }
4981    }
4982
4983    /// Update an existing incident integration metadata.
4984    pub async fn update_incident_integration(
4985        &self,
4986        incident_id: String,
4987        integration_metadata_id: String,
4988        body: crate::datadogV2::model::IncidentIntegrationMetadataPatchRequest,
4989    ) -> Result<
4990        crate::datadogV2::model::IncidentIntegrationMetadataResponse,
4991        datadog::Error<UpdateIncidentIntegrationError>,
4992    > {
4993        match self
4994            .update_incident_integration_with_http_info(incident_id, integration_metadata_id, body)
4995            .await
4996        {
4997            Ok(response_content) => {
4998                if let Some(e) = response_content.entity {
4999                    Ok(e)
5000                } else {
5001                    Err(datadog::Error::Serde(serde::de::Error::custom(
5002                        "response content was None",
5003                    )))
5004                }
5005            }
5006            Err(err) => Err(err),
5007        }
5008    }
5009
5010    /// Update an existing incident integration metadata.
5011    pub async fn update_incident_integration_with_http_info(
5012        &self,
5013        incident_id: String,
5014        integration_metadata_id: String,
5015        body: crate::datadogV2::model::IncidentIntegrationMetadataPatchRequest,
5016    ) -> Result<
5017        datadog::ResponseContent<crate::datadogV2::model::IncidentIntegrationMetadataResponse>,
5018        datadog::Error<UpdateIncidentIntegrationError>,
5019    > {
5020        let local_configuration = &self.config;
5021        let operation_id = "v2.update_incident_integration";
5022        if local_configuration.is_unstable_operation_enabled(operation_id) {
5023            warn!("Using unstable operation {operation_id}");
5024        } else {
5025            let local_error = datadog::UnstableOperationDisabledError {
5026                msg: "Operation 'v2.update_incident_integration' is not enabled".to_string(),
5027            };
5028            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5029        }
5030
5031        let local_client = &self.client;
5032
5033        let local_uri_str = format!(
5034            "{}/api/v2/incidents/{incident_id}/relationships/integrations/{integration_metadata_id}",
5035            local_configuration.get_operation_host(operation_id), incident_id=
5036            datadog::urlencode(incident_id)
5037            , integration_metadata_id=
5038            datadog::urlencode(integration_metadata_id)
5039            );
5040        let mut local_req_builder =
5041            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
5042
5043        // build headers
5044        let mut headers = HeaderMap::new();
5045        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5046        headers.insert("Accept", HeaderValue::from_static("application/json"));
5047
5048        // build user agent
5049        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5050            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5051            Err(e) => {
5052                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5053                headers.insert(
5054                    reqwest::header::USER_AGENT,
5055                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5056                )
5057            }
5058        };
5059
5060        // build auth
5061        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5062            headers.insert(
5063                "DD-API-KEY",
5064                HeaderValue::from_str(local_key.key.as_str())
5065                    .expect("failed to parse DD-API-KEY header"),
5066            );
5067        };
5068        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5069            headers.insert(
5070                "DD-APPLICATION-KEY",
5071                HeaderValue::from_str(local_key.key.as_str())
5072                    .expect("failed to parse DD-APPLICATION-KEY header"),
5073            );
5074        };
5075
5076        // build body parameters
5077        let output = Vec::new();
5078        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5079        if body.serialize(&mut ser).is_ok() {
5080            if let Some(content_encoding) = headers.get("Content-Encoding") {
5081                match content_encoding.to_str().unwrap_or_default() {
5082                    "gzip" => {
5083                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5084                        let _ = enc.write_all(ser.into_inner().as_slice());
5085                        match enc.finish() {
5086                            Ok(buf) => {
5087                                local_req_builder = local_req_builder.body(buf);
5088                            }
5089                            Err(e) => return Err(datadog::Error::Io(e)),
5090                        }
5091                    }
5092                    "deflate" => {
5093                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5094                        let _ = enc.write_all(ser.into_inner().as_slice());
5095                        match enc.finish() {
5096                            Ok(buf) => {
5097                                local_req_builder = local_req_builder.body(buf);
5098                            }
5099                            Err(e) => return Err(datadog::Error::Io(e)),
5100                        }
5101                    }
5102                    "zstd1" => {
5103                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5104                        let _ = enc.write_all(ser.into_inner().as_slice());
5105                        match enc.finish() {
5106                            Ok(buf) => {
5107                                local_req_builder = local_req_builder.body(buf);
5108                            }
5109                            Err(e) => return Err(datadog::Error::Io(e)),
5110                        }
5111                    }
5112                    _ => {
5113                        local_req_builder = local_req_builder.body(ser.into_inner());
5114                    }
5115                }
5116            } else {
5117                local_req_builder = local_req_builder.body(ser.into_inner());
5118            }
5119        }
5120
5121        local_req_builder = local_req_builder.headers(headers);
5122        let local_req = local_req_builder.build()?;
5123        log::debug!("request content: {:?}", local_req.body());
5124        let local_resp = local_client.execute(local_req).await?;
5125
5126        let local_status = local_resp.status();
5127        let local_content = local_resp.text().await?;
5128        log::debug!("response content: {}", local_content);
5129
5130        if !local_status.is_client_error() && !local_status.is_server_error() {
5131            match serde_json::from_str::<crate::datadogV2::model::IncidentIntegrationMetadataResponse>(
5132                &local_content,
5133            ) {
5134                Ok(e) => {
5135                    return Ok(datadog::ResponseContent {
5136                        status: local_status,
5137                        content: local_content,
5138                        entity: Some(e),
5139                    })
5140                }
5141                Err(e) => return Err(datadog::Error::Serde(e)),
5142            };
5143        } else {
5144            let local_entity: Option<UpdateIncidentIntegrationError> =
5145                serde_json::from_str(&local_content).ok();
5146            let local_error = datadog::ResponseContent {
5147                status: local_status,
5148                content: local_content,
5149                entity: local_entity,
5150            };
5151            Err(datadog::Error::ResponseError(local_error))
5152        }
5153    }
5154
5155    /// Updates an existing notification rule with a complete replacement.
5156    pub async fn update_incident_notification_rule(
5157        &self,
5158        id: uuid::Uuid,
5159        body: crate::datadogV2::model::PutIncidentNotificationRuleRequest,
5160        params: UpdateIncidentNotificationRuleOptionalParams,
5161    ) -> Result<
5162        crate::datadogV2::model::IncidentNotificationRule,
5163        datadog::Error<UpdateIncidentNotificationRuleError>,
5164    > {
5165        match self
5166            .update_incident_notification_rule_with_http_info(id, body, params)
5167            .await
5168        {
5169            Ok(response_content) => {
5170                if let Some(e) = response_content.entity {
5171                    Ok(e)
5172                } else {
5173                    Err(datadog::Error::Serde(serde::de::Error::custom(
5174                        "response content was None",
5175                    )))
5176                }
5177            }
5178            Err(err) => Err(err),
5179        }
5180    }
5181
5182    /// Updates an existing notification rule with a complete replacement.
5183    pub async fn update_incident_notification_rule_with_http_info(
5184        &self,
5185        id: uuid::Uuid,
5186        body: crate::datadogV2::model::PutIncidentNotificationRuleRequest,
5187        params: UpdateIncidentNotificationRuleOptionalParams,
5188    ) -> Result<
5189        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationRule>,
5190        datadog::Error<UpdateIncidentNotificationRuleError>,
5191    > {
5192        let local_configuration = &self.config;
5193        let operation_id = "v2.update_incident_notification_rule";
5194        if local_configuration.is_unstable_operation_enabled(operation_id) {
5195            warn!("Using unstable operation {operation_id}");
5196        } else {
5197            let local_error = datadog::UnstableOperationDisabledError {
5198                msg: "Operation 'v2.update_incident_notification_rule' is not enabled".to_string(),
5199            };
5200            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5201        }
5202
5203        // unbox and build optional parameters
5204        let include = params.include;
5205
5206        let local_client = &self.client;
5207
5208        let local_uri_str = format!(
5209            "{}/api/v2/incidents/config/notification-rules/{id}",
5210            local_configuration.get_operation_host(operation_id),
5211            id = datadog::urlencode(id.to_string())
5212        );
5213        let mut local_req_builder =
5214            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
5215
5216        if let Some(ref local_query_param) = include {
5217            local_req_builder =
5218                local_req_builder.query(&[("include", &local_query_param.to_string())]);
5219        };
5220
5221        // build headers
5222        let mut headers = HeaderMap::new();
5223        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5224        headers.insert("Accept", HeaderValue::from_static("application/json"));
5225
5226        // build user agent
5227        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5228            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5229            Err(e) => {
5230                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5231                headers.insert(
5232                    reqwest::header::USER_AGENT,
5233                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5234                )
5235            }
5236        };
5237
5238        // build auth
5239        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5240            headers.insert(
5241                "DD-API-KEY",
5242                HeaderValue::from_str(local_key.key.as_str())
5243                    .expect("failed to parse DD-API-KEY header"),
5244            );
5245        };
5246        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5247            headers.insert(
5248                "DD-APPLICATION-KEY",
5249                HeaderValue::from_str(local_key.key.as_str())
5250                    .expect("failed to parse DD-APPLICATION-KEY header"),
5251            );
5252        };
5253
5254        // build body parameters
5255        let output = Vec::new();
5256        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5257        if body.serialize(&mut ser).is_ok() {
5258            if let Some(content_encoding) = headers.get("Content-Encoding") {
5259                match content_encoding.to_str().unwrap_or_default() {
5260                    "gzip" => {
5261                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5262                        let _ = enc.write_all(ser.into_inner().as_slice());
5263                        match enc.finish() {
5264                            Ok(buf) => {
5265                                local_req_builder = local_req_builder.body(buf);
5266                            }
5267                            Err(e) => return Err(datadog::Error::Io(e)),
5268                        }
5269                    }
5270                    "deflate" => {
5271                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5272                        let _ = enc.write_all(ser.into_inner().as_slice());
5273                        match enc.finish() {
5274                            Ok(buf) => {
5275                                local_req_builder = local_req_builder.body(buf);
5276                            }
5277                            Err(e) => return Err(datadog::Error::Io(e)),
5278                        }
5279                    }
5280                    "zstd1" => {
5281                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5282                        let _ = enc.write_all(ser.into_inner().as_slice());
5283                        match enc.finish() {
5284                            Ok(buf) => {
5285                                local_req_builder = local_req_builder.body(buf);
5286                            }
5287                            Err(e) => return Err(datadog::Error::Io(e)),
5288                        }
5289                    }
5290                    _ => {
5291                        local_req_builder = local_req_builder.body(ser.into_inner());
5292                    }
5293                }
5294            } else {
5295                local_req_builder = local_req_builder.body(ser.into_inner());
5296            }
5297        }
5298
5299        local_req_builder = local_req_builder.headers(headers);
5300        let local_req = local_req_builder.build()?;
5301        log::debug!("request content: {:?}", local_req.body());
5302        let local_resp = local_client.execute(local_req).await?;
5303
5304        let local_status = local_resp.status();
5305        let local_content = local_resp.text().await?;
5306        log::debug!("response content: {}", local_content);
5307
5308        if !local_status.is_client_error() && !local_status.is_server_error() {
5309            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationRule>(
5310                &local_content,
5311            ) {
5312                Ok(e) => {
5313                    return Ok(datadog::ResponseContent {
5314                        status: local_status,
5315                        content: local_content,
5316                        entity: Some(e),
5317                    })
5318                }
5319                Err(e) => return Err(datadog::Error::Serde(e)),
5320            };
5321        } else {
5322            let local_entity: Option<UpdateIncidentNotificationRuleError> =
5323                serde_json::from_str(&local_content).ok();
5324            let local_error = datadog::ResponseContent {
5325                status: local_status,
5326                content: local_content,
5327                entity: local_entity,
5328            };
5329            Err(datadog::Error::ResponseError(local_error))
5330        }
5331    }
5332
5333    /// Updates an existing notification template's attributes.
5334    pub async fn update_incident_notification_template(
5335        &self,
5336        id: uuid::Uuid,
5337        body: crate::datadogV2::model::PatchIncidentNotificationTemplateRequest,
5338        params: UpdateIncidentNotificationTemplateOptionalParams,
5339    ) -> Result<
5340        crate::datadogV2::model::IncidentNotificationTemplate,
5341        datadog::Error<UpdateIncidentNotificationTemplateError>,
5342    > {
5343        match self
5344            .update_incident_notification_template_with_http_info(id, body, params)
5345            .await
5346        {
5347            Ok(response_content) => {
5348                if let Some(e) = response_content.entity {
5349                    Ok(e)
5350                } else {
5351                    Err(datadog::Error::Serde(serde::de::Error::custom(
5352                        "response content was None",
5353                    )))
5354                }
5355            }
5356            Err(err) => Err(err),
5357        }
5358    }
5359
5360    /// Updates an existing notification template's attributes.
5361    pub async fn update_incident_notification_template_with_http_info(
5362        &self,
5363        id: uuid::Uuid,
5364        body: crate::datadogV2::model::PatchIncidentNotificationTemplateRequest,
5365        params: UpdateIncidentNotificationTemplateOptionalParams,
5366    ) -> Result<
5367        datadog::ResponseContent<crate::datadogV2::model::IncidentNotificationTemplate>,
5368        datadog::Error<UpdateIncidentNotificationTemplateError>,
5369    > {
5370        let local_configuration = &self.config;
5371        let operation_id = "v2.update_incident_notification_template";
5372        if local_configuration.is_unstable_operation_enabled(operation_id) {
5373            warn!("Using unstable operation {operation_id}");
5374        } else {
5375            let local_error = datadog::UnstableOperationDisabledError {
5376                msg: "Operation 'v2.update_incident_notification_template' is not enabled"
5377                    .to_string(),
5378            };
5379            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5380        }
5381
5382        // unbox and build optional parameters
5383        let include = params.include;
5384
5385        let local_client = &self.client;
5386
5387        let local_uri_str = format!(
5388            "{}/api/v2/incidents/config/notification-templates/{id}",
5389            local_configuration.get_operation_host(operation_id),
5390            id = datadog::urlencode(id.to_string())
5391        );
5392        let mut local_req_builder =
5393            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
5394
5395        if let Some(ref local_query_param) = include {
5396            local_req_builder =
5397                local_req_builder.query(&[("include", &local_query_param.to_string())]);
5398        };
5399
5400        // build headers
5401        let mut headers = HeaderMap::new();
5402        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5403        headers.insert("Accept", HeaderValue::from_static("application/json"));
5404
5405        // build user agent
5406        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5407            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5408            Err(e) => {
5409                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5410                headers.insert(
5411                    reqwest::header::USER_AGENT,
5412                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5413                )
5414            }
5415        };
5416
5417        // build auth
5418        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5419            headers.insert(
5420                "DD-API-KEY",
5421                HeaderValue::from_str(local_key.key.as_str())
5422                    .expect("failed to parse DD-API-KEY header"),
5423            );
5424        };
5425        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5426            headers.insert(
5427                "DD-APPLICATION-KEY",
5428                HeaderValue::from_str(local_key.key.as_str())
5429                    .expect("failed to parse DD-APPLICATION-KEY header"),
5430            );
5431        };
5432
5433        // build body parameters
5434        let output = Vec::new();
5435        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5436        if body.serialize(&mut ser).is_ok() {
5437            if let Some(content_encoding) = headers.get("Content-Encoding") {
5438                match content_encoding.to_str().unwrap_or_default() {
5439                    "gzip" => {
5440                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5441                        let _ = enc.write_all(ser.into_inner().as_slice());
5442                        match enc.finish() {
5443                            Ok(buf) => {
5444                                local_req_builder = local_req_builder.body(buf);
5445                            }
5446                            Err(e) => return Err(datadog::Error::Io(e)),
5447                        }
5448                    }
5449                    "deflate" => {
5450                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5451                        let _ = enc.write_all(ser.into_inner().as_slice());
5452                        match enc.finish() {
5453                            Ok(buf) => {
5454                                local_req_builder = local_req_builder.body(buf);
5455                            }
5456                            Err(e) => return Err(datadog::Error::Io(e)),
5457                        }
5458                    }
5459                    "zstd1" => {
5460                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5461                        let _ = enc.write_all(ser.into_inner().as_slice());
5462                        match enc.finish() {
5463                            Ok(buf) => {
5464                                local_req_builder = local_req_builder.body(buf);
5465                            }
5466                            Err(e) => return Err(datadog::Error::Io(e)),
5467                        }
5468                    }
5469                    _ => {
5470                        local_req_builder = local_req_builder.body(ser.into_inner());
5471                    }
5472                }
5473            } else {
5474                local_req_builder = local_req_builder.body(ser.into_inner());
5475            }
5476        }
5477
5478        local_req_builder = local_req_builder.headers(headers);
5479        let local_req = local_req_builder.build()?;
5480        log::debug!("request content: {:?}", local_req.body());
5481        let local_resp = local_client.execute(local_req).await?;
5482
5483        let local_status = local_resp.status();
5484        let local_content = local_resp.text().await?;
5485        log::debug!("response content: {}", local_content);
5486
5487        if !local_status.is_client_error() && !local_status.is_server_error() {
5488            match serde_json::from_str::<crate::datadogV2::model::IncidentNotificationTemplate>(
5489                &local_content,
5490            ) {
5491                Ok(e) => {
5492                    return Ok(datadog::ResponseContent {
5493                        status: local_status,
5494                        content: local_content,
5495                        entity: Some(e),
5496                    })
5497                }
5498                Err(e) => return Err(datadog::Error::Serde(e)),
5499            };
5500        } else {
5501            let local_entity: Option<UpdateIncidentNotificationTemplateError> =
5502                serde_json::from_str(&local_content).ok();
5503            let local_error = datadog::ResponseContent {
5504                status: local_status,
5505                content: local_content,
5506                entity: local_entity,
5507            };
5508            Err(datadog::Error::ResponseError(local_error))
5509        }
5510    }
5511
5512    /// Update an incident todo.
5513    pub async fn update_incident_todo(
5514        &self,
5515        incident_id: String,
5516        todo_id: String,
5517        body: crate::datadogV2::model::IncidentTodoPatchRequest,
5518    ) -> Result<
5519        crate::datadogV2::model::IncidentTodoResponse,
5520        datadog::Error<UpdateIncidentTodoError>,
5521    > {
5522        match self
5523            .update_incident_todo_with_http_info(incident_id, todo_id, body)
5524            .await
5525        {
5526            Ok(response_content) => {
5527                if let Some(e) = response_content.entity {
5528                    Ok(e)
5529                } else {
5530                    Err(datadog::Error::Serde(serde::de::Error::custom(
5531                        "response content was None",
5532                    )))
5533                }
5534            }
5535            Err(err) => Err(err),
5536        }
5537    }
5538
5539    /// Update an incident todo.
5540    pub async fn update_incident_todo_with_http_info(
5541        &self,
5542        incident_id: String,
5543        todo_id: String,
5544        body: crate::datadogV2::model::IncidentTodoPatchRequest,
5545    ) -> Result<
5546        datadog::ResponseContent<crate::datadogV2::model::IncidentTodoResponse>,
5547        datadog::Error<UpdateIncidentTodoError>,
5548    > {
5549        let local_configuration = &self.config;
5550        let operation_id = "v2.update_incident_todo";
5551        if local_configuration.is_unstable_operation_enabled(operation_id) {
5552            warn!("Using unstable operation {operation_id}");
5553        } else {
5554            let local_error = datadog::UnstableOperationDisabledError {
5555                msg: "Operation 'v2.update_incident_todo' is not enabled".to_string(),
5556            };
5557            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5558        }
5559
5560        let local_client = &self.client;
5561
5562        let local_uri_str = format!(
5563            "{}/api/v2/incidents/{incident_id}/relationships/todos/{todo_id}",
5564            local_configuration.get_operation_host(operation_id),
5565            incident_id = datadog::urlencode(incident_id),
5566            todo_id = datadog::urlencode(todo_id)
5567        );
5568        let mut local_req_builder =
5569            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
5570
5571        // build headers
5572        let mut headers = HeaderMap::new();
5573        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5574        headers.insert("Accept", HeaderValue::from_static("application/json"));
5575
5576        // build user agent
5577        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5578            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5579            Err(e) => {
5580                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5581                headers.insert(
5582                    reqwest::header::USER_AGENT,
5583                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5584                )
5585            }
5586        };
5587
5588        // build auth
5589        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5590            headers.insert(
5591                "DD-API-KEY",
5592                HeaderValue::from_str(local_key.key.as_str())
5593                    .expect("failed to parse DD-API-KEY header"),
5594            );
5595        };
5596        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5597            headers.insert(
5598                "DD-APPLICATION-KEY",
5599                HeaderValue::from_str(local_key.key.as_str())
5600                    .expect("failed to parse DD-APPLICATION-KEY header"),
5601            );
5602        };
5603
5604        // build body parameters
5605        let output = Vec::new();
5606        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5607        if body.serialize(&mut ser).is_ok() {
5608            if let Some(content_encoding) = headers.get("Content-Encoding") {
5609                match content_encoding.to_str().unwrap_or_default() {
5610                    "gzip" => {
5611                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5612                        let _ = enc.write_all(ser.into_inner().as_slice());
5613                        match enc.finish() {
5614                            Ok(buf) => {
5615                                local_req_builder = local_req_builder.body(buf);
5616                            }
5617                            Err(e) => return Err(datadog::Error::Io(e)),
5618                        }
5619                    }
5620                    "deflate" => {
5621                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5622                        let _ = enc.write_all(ser.into_inner().as_slice());
5623                        match enc.finish() {
5624                            Ok(buf) => {
5625                                local_req_builder = local_req_builder.body(buf);
5626                            }
5627                            Err(e) => return Err(datadog::Error::Io(e)),
5628                        }
5629                    }
5630                    "zstd1" => {
5631                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5632                        let _ = enc.write_all(ser.into_inner().as_slice());
5633                        match enc.finish() {
5634                            Ok(buf) => {
5635                                local_req_builder = local_req_builder.body(buf);
5636                            }
5637                            Err(e) => return Err(datadog::Error::Io(e)),
5638                        }
5639                    }
5640                    _ => {
5641                        local_req_builder = local_req_builder.body(ser.into_inner());
5642                    }
5643                }
5644            } else {
5645                local_req_builder = local_req_builder.body(ser.into_inner());
5646            }
5647        }
5648
5649        local_req_builder = local_req_builder.headers(headers);
5650        let local_req = local_req_builder.build()?;
5651        log::debug!("request content: {:?}", local_req.body());
5652        let local_resp = local_client.execute(local_req).await?;
5653
5654        let local_status = local_resp.status();
5655        let local_content = local_resp.text().await?;
5656        log::debug!("response content: {}", local_content);
5657
5658        if !local_status.is_client_error() && !local_status.is_server_error() {
5659            match serde_json::from_str::<crate::datadogV2::model::IncidentTodoResponse>(
5660                &local_content,
5661            ) {
5662                Ok(e) => {
5663                    return Ok(datadog::ResponseContent {
5664                        status: local_status,
5665                        content: local_content,
5666                        entity: Some(e),
5667                    })
5668                }
5669                Err(e) => return Err(datadog::Error::Serde(e)),
5670            };
5671        } else {
5672            let local_entity: Option<UpdateIncidentTodoError> =
5673                serde_json::from_str(&local_content).ok();
5674            let local_error = datadog::ResponseContent {
5675                status: local_status,
5676                content: local_content,
5677                entity: local_entity,
5678            };
5679            Err(datadog::Error::ResponseError(local_error))
5680        }
5681    }
5682
5683    /// Update an incident type.
5684    pub async fn update_incident_type(
5685        &self,
5686        incident_type_id: String,
5687        body: crate::datadogV2::model::IncidentTypePatchRequest,
5688    ) -> Result<
5689        crate::datadogV2::model::IncidentTypeResponse,
5690        datadog::Error<UpdateIncidentTypeError>,
5691    > {
5692        match self
5693            .update_incident_type_with_http_info(incident_type_id, body)
5694            .await
5695        {
5696            Ok(response_content) => {
5697                if let Some(e) = response_content.entity {
5698                    Ok(e)
5699                } else {
5700                    Err(datadog::Error::Serde(serde::de::Error::custom(
5701                        "response content was None",
5702                    )))
5703                }
5704            }
5705            Err(err) => Err(err),
5706        }
5707    }
5708
5709    /// Update an incident type.
5710    pub async fn update_incident_type_with_http_info(
5711        &self,
5712        incident_type_id: String,
5713        body: crate::datadogV2::model::IncidentTypePatchRequest,
5714    ) -> Result<
5715        datadog::ResponseContent<crate::datadogV2::model::IncidentTypeResponse>,
5716        datadog::Error<UpdateIncidentTypeError>,
5717    > {
5718        let local_configuration = &self.config;
5719        let operation_id = "v2.update_incident_type";
5720        if local_configuration.is_unstable_operation_enabled(operation_id) {
5721            warn!("Using unstable operation {operation_id}");
5722        } else {
5723            let local_error = datadog::UnstableOperationDisabledError {
5724                msg: "Operation 'v2.update_incident_type' is not enabled".to_string(),
5725            };
5726            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5727        }
5728
5729        let local_client = &self.client;
5730
5731        let local_uri_str = format!(
5732            "{}/api/v2/incidents/config/types/{incident_type_id}",
5733            local_configuration.get_operation_host(operation_id),
5734            incident_type_id = datadog::urlencode(incident_type_id)
5735        );
5736        let mut local_req_builder =
5737            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
5738
5739        // build headers
5740        let mut headers = HeaderMap::new();
5741        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5742        headers.insert("Accept", HeaderValue::from_static("application/json"));
5743
5744        // build user agent
5745        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5746            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5747            Err(e) => {
5748                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5749                headers.insert(
5750                    reqwest::header::USER_AGENT,
5751                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5752                )
5753            }
5754        };
5755
5756        // build auth
5757        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5758            headers.insert(
5759                "DD-API-KEY",
5760                HeaderValue::from_str(local_key.key.as_str())
5761                    .expect("failed to parse DD-API-KEY header"),
5762            );
5763        };
5764        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5765            headers.insert(
5766                "DD-APPLICATION-KEY",
5767                HeaderValue::from_str(local_key.key.as_str())
5768                    .expect("failed to parse DD-APPLICATION-KEY header"),
5769            );
5770        };
5771
5772        // build body parameters
5773        let output = Vec::new();
5774        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5775        if body.serialize(&mut ser).is_ok() {
5776            if let Some(content_encoding) = headers.get("Content-Encoding") {
5777                match content_encoding.to_str().unwrap_or_default() {
5778                    "gzip" => {
5779                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5780                        let _ = enc.write_all(ser.into_inner().as_slice());
5781                        match enc.finish() {
5782                            Ok(buf) => {
5783                                local_req_builder = local_req_builder.body(buf);
5784                            }
5785                            Err(e) => return Err(datadog::Error::Io(e)),
5786                        }
5787                    }
5788                    "deflate" => {
5789                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5790                        let _ = enc.write_all(ser.into_inner().as_slice());
5791                        match enc.finish() {
5792                            Ok(buf) => {
5793                                local_req_builder = local_req_builder.body(buf);
5794                            }
5795                            Err(e) => return Err(datadog::Error::Io(e)),
5796                        }
5797                    }
5798                    "zstd1" => {
5799                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5800                        let _ = enc.write_all(ser.into_inner().as_slice());
5801                        match enc.finish() {
5802                            Ok(buf) => {
5803                                local_req_builder = local_req_builder.body(buf);
5804                            }
5805                            Err(e) => return Err(datadog::Error::Io(e)),
5806                        }
5807                    }
5808                    _ => {
5809                        local_req_builder = local_req_builder.body(ser.into_inner());
5810                    }
5811                }
5812            } else {
5813                local_req_builder = local_req_builder.body(ser.into_inner());
5814            }
5815        }
5816
5817        local_req_builder = local_req_builder.headers(headers);
5818        let local_req = local_req_builder.build()?;
5819        log::debug!("request content: {:?}", local_req.body());
5820        let local_resp = local_client.execute(local_req).await?;
5821
5822        let local_status = local_resp.status();
5823        let local_content = local_resp.text().await?;
5824        log::debug!("response content: {}", local_content);
5825
5826        if !local_status.is_client_error() && !local_status.is_server_error() {
5827            match serde_json::from_str::<crate::datadogV2::model::IncidentTypeResponse>(
5828                &local_content,
5829            ) {
5830                Ok(e) => {
5831                    return Ok(datadog::ResponseContent {
5832                        status: local_status,
5833                        content: local_content,
5834                        entity: Some(e),
5835                    })
5836                }
5837                Err(e) => return Err(datadog::Error::Serde(e)),
5838            };
5839        } else {
5840            let local_entity: Option<UpdateIncidentTypeError> =
5841                serde_json::from_str(&local_content).ok();
5842            let local_error = datadog::ResponseContent {
5843                status: local_status,
5844                content: local_content,
5845                entity: local_entity,
5846            };
5847            Err(datadog::Error::ResponseError(local_error))
5848        }
5849    }
5850}