Skip to content

Commit ea8363a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Expand incidents postmortem-templates spec to full CRUD contract (#1857)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent fbbe112 commit ea8363a

25 files changed

Lines changed: 1608 additions & 62 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 239 additions & 35 deletions
Large diffs are not rendered by default.

examples/v2_incidents_CreateIncidentPostmortemTemplate.rs

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,60 @@
11
// Create postmortem template returns "Created" response
2+
use chrono::{DateTime, Utc};
23
use datadog_api_client::datadog;
34
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
5+
use datadog_api_client::datadogV2::model::ConfluencePostmortemSettings;
6+
use datadog_api_client::datadogV2::model::GoogleDocsPostmortemSettings;
47
use datadog_api_client::datadogV2::model::PostmortemTemplateAttributesRequest;
8+
use datadog_api_client::datadogV2::model::PostmortemTemplateCreateRelationships;
59
use datadog_api_client::datadogV2::model::PostmortemTemplateDataRequest;
10+
use datadog_api_client::datadogV2::model::PostmortemTemplateIncidentTypeRelationship;
11+
use datadog_api_client::datadogV2::model::PostmortemTemplateIncidentTypeRelationshipData;
12+
use datadog_api_client::datadogV2::model::PostmortemTemplateLocation;
613
use datadog_api_client::datadogV2::model::PostmortemTemplateRequest;
714
use datadog_api_client::datadogV2::model::PostmortemTemplateType;
15+
use uuid::Uuid;
816

917
#[tokio::main]
1018
async fn main() {
11-
let body = PostmortemTemplateRequest::new(PostmortemTemplateDataRequest::new(
12-
PostmortemTemplateAttributesRequest::new("Standard Postmortem Template".to_string()),
13-
PostmortemTemplateType::POSTMORTEM_TEMPLATE,
14-
));
19+
let body = PostmortemTemplateRequest::new(
20+
PostmortemTemplateDataRequest::new(
21+
PostmortemTemplateAttributesRequest::new("Standard Postmortem Template".to_string())
22+
.confluence_postmortem_settings(
23+
ConfluencePostmortemSettings::new("123456".to_string(), "789012".to_string())
24+
.parent_id(Some("345678".to_string())),
25+
)
26+
.content(
27+
r#"# Overview
28+
29+
# What Happened
30+
31+
# Timeline
32+
33+
# Action Items"#
34+
.to_string(),
35+
)
36+
.google_docs_postmortem_settings(GoogleDocsPostmortemSettings::new(
37+
"123456".to_string(),
38+
"789012".to_string(),
39+
))
40+
.is_default(Some(
41+
DateTime::parse_from_rfc3339("2024-01-01T00:00:00+00:00")
42+
.expect("Failed to parse datetime")
43+
.with_timezone(&Utc),
44+
))
45+
.location(PostmortemTemplateLocation::DATADOG_NOTEBOOKS),
46+
PostmortemTemplateType::POSTMORTEM_TEMPLATES,
47+
)
48+
.id("00000000-0000-0000-0000-000000000000".to_string())
49+
.relationships(PostmortemTemplateCreateRelationships::new().incident_type(
50+
PostmortemTemplateIncidentTypeRelationship::new(
51+
PostmortemTemplateIncidentTypeRelationshipData::new(
52+
Uuid::parse_str("00000000-0000-0000-0000-000000000009").expect("invalid UUID"),
53+
"incident_types".to_string(),
54+
),
55+
),
56+
)),
57+
);
1558
let mut configuration = datadog::Configuration::new();
1659
configuration.set_unstable_operation_enabled("v2.CreateIncidentPostmortemTemplate", true);
1760
let api = IncidentsAPI::with_config(configuration);

examples/v2_incidents_DeleteIncidentPostmortemTemplate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async fn main() {
88
configuration.set_unstable_operation_enabled("v2.DeleteIncidentPostmortemTemplate", true);
99
let api = IncidentsAPI::with_config(configuration);
1010
let resp = api
11-
.delete_incident_postmortem_template("template-456".to_string())
11+
.delete_incident_postmortem_template("template_id".to_string())
1212
.await;
1313
if let Ok(value) = resp {
1414
println!("{:#?}", value);

examples/v2_incidents_GetIncidentPostmortemTemplate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async fn main() {
88
configuration.set_unstable_operation_enabled("v2.GetIncidentPostmortemTemplate", true);
99
let api = IncidentsAPI::with_config(configuration);
1010
let resp = api
11-
.get_incident_postmortem_template("template-456".to_string())
11+
.get_incident_postmortem_template("template_id".to_string())
1212
.await;
1313
if let Ok(value) = resp {
1414
println!("{:#?}", value);

examples/v2_incidents_ListIncidentPostmortemTemplates.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// List postmortem templates returns "OK" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
4+
use datadog_api_client::datadogV2::api_incidents::ListIncidentPostmortemTemplatesOptionalParams;
45

56
#[tokio::main]
67
async fn main() {
78
let mut configuration = datadog::Configuration::new();
89
configuration.set_unstable_operation_enabled("v2.ListIncidentPostmortemTemplates", true);
910
let api = IncidentsAPI::with_config(configuration);
10-
let resp = api.list_incident_postmortem_templates().await;
11+
let resp =
12+
api.list_incident_postmortem_templates(
13+
ListIncidentPostmortemTemplatesOptionalParams::default(),
14+
)
15+
.await;
1116
if let Ok(value) = resp {
1217
println!("{:#?}", value);
1318
} else {

examples/v2_incidents_UpdateIncidentPostmortemTemplate.rs

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,65 @@
11
// Update postmortem template returns "OK" response
2+
use chrono::{DateTime, Utc};
23
use datadog_api_client::datadog;
34
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
5+
use datadog_api_client::datadogV2::model::ConfluencePostmortemSettings;
6+
use datadog_api_client::datadogV2::model::GoogleDocsPostmortemSettings;
47
use datadog_api_client::datadogV2::model::PostmortemTemplateAttributesRequest;
8+
use datadog_api_client::datadogV2::model::PostmortemTemplateCreateRelationships;
59
use datadog_api_client::datadogV2::model::PostmortemTemplateDataRequest;
10+
use datadog_api_client::datadogV2::model::PostmortemTemplateIncidentTypeRelationship;
11+
use datadog_api_client::datadogV2::model::PostmortemTemplateIncidentTypeRelationshipData;
12+
use datadog_api_client::datadogV2::model::PostmortemTemplateLocation;
613
use datadog_api_client::datadogV2::model::PostmortemTemplateRequest;
714
use datadog_api_client::datadogV2::model::PostmortemTemplateType;
15+
use uuid::Uuid;
816

917
#[tokio::main]
1018
async fn main() {
11-
let body = PostmortemTemplateRequest::new(PostmortemTemplateDataRequest::new(
12-
PostmortemTemplateAttributesRequest::new("Standard Postmortem Template".to_string()),
13-
PostmortemTemplateType::POSTMORTEM_TEMPLATE,
14-
));
19+
let body = PostmortemTemplateRequest::new(
20+
PostmortemTemplateDataRequest::new(
21+
PostmortemTemplateAttributesRequest::new("Standard Postmortem Template".to_string())
22+
.confluence_postmortem_settings(
23+
ConfluencePostmortemSettings::new("123456".to_string(), "789012".to_string())
24+
.parent_id(Some("345678".to_string())),
25+
)
26+
.content(
27+
r#"# Overview
28+
29+
# What Happened
30+
31+
# Timeline
32+
33+
# Action Items"#
34+
.to_string(),
35+
)
36+
.google_docs_postmortem_settings(GoogleDocsPostmortemSettings::new(
37+
"123456".to_string(),
38+
"789012".to_string(),
39+
))
40+
.is_default(Some(
41+
DateTime::parse_from_rfc3339("2024-01-01T00:00:00+00:00")
42+
.expect("Failed to parse datetime")
43+
.with_timezone(&Utc),
44+
))
45+
.location(PostmortemTemplateLocation::DATADOG_NOTEBOOKS),
46+
PostmortemTemplateType::POSTMORTEM_TEMPLATES,
47+
)
48+
.id("00000000-0000-0000-0000-000000000000".to_string())
49+
.relationships(PostmortemTemplateCreateRelationships::new().incident_type(
50+
PostmortemTemplateIncidentTypeRelationship::new(
51+
PostmortemTemplateIncidentTypeRelationshipData::new(
52+
Uuid::parse_str("00000000-0000-0000-0000-000000000009").expect("invalid UUID"),
53+
"incident_types".to_string(),
54+
),
55+
),
56+
)),
57+
);
1558
let mut configuration = datadog::Configuration::new();
1659
configuration.set_unstable_operation_enabled("v2.UpdateIncidentPostmortemTemplate", true);
1760
let api = IncidentsAPI::with_config(configuration);
1861
let resp = api
19-
.update_incident_postmortem_template("template-456".to_string(), body)
62+
.update_incident_postmortem_template("template_id".to_string(), body)
2063
.await;
2164
if let Ok(value) = resp {
2265
println!("{:#?}", value);

src/datadogV2/api/api_incidents.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,29 @@ impl ListIncidentNotificationTemplatesOptionalParams {
324324
}
325325
}
326326

327+
/// ListIncidentPostmortemTemplatesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_postmortem_templates`]
328+
#[non_exhaustive]
329+
#[derive(Clone, Default, Debug)]
330+
pub struct ListIncidentPostmortemTemplatesOptionalParams {
331+
/// Filter postmortem templates by the associated incident type ID.
332+
pub filter_incident_type: Option<uuid::Uuid>,
333+
/// The attribute to sort results by. Prefix with `-` for descending order.
334+
pub sort: Option<String>,
335+
}
336+
337+
impl ListIncidentPostmortemTemplatesOptionalParams {
338+
/// Filter postmortem templates by the associated incident type ID.
339+
pub fn filter_incident_type(mut self, value: uuid::Uuid) -> Self {
340+
self.filter_incident_type = Some(value);
341+
self
342+
}
343+
/// The attribute to sort results by. Prefix with `-` for descending order.
344+
pub fn sort(mut self, value: String) -> Self {
345+
self.sort = Some(value);
346+
self
347+
}
348+
}
349+
327350
/// ListIncidentTypesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_types`]
328351
#[non_exhaustive]
329352
#[derive(Clone, Default, Debug)]
@@ -6798,12 +6821,13 @@ impl IncidentsAPI {
67986821
/// Retrieve a list of all postmortem templates for incidents.
67996822
pub async fn list_incident_postmortem_templates(
68006823
&self,
6824+
params: ListIncidentPostmortemTemplatesOptionalParams,
68016825
) -> Result<
68026826
crate::datadogV2::model::PostmortemTemplatesResponse,
68036827
datadog::Error<ListIncidentPostmortemTemplatesError>,
68046828
> {
68056829
match self
6806-
.list_incident_postmortem_templates_with_http_info()
6830+
.list_incident_postmortem_templates_with_http_info(params)
68076831
.await
68086832
{
68096833
Ok(response_content) => {
@@ -6822,6 +6846,7 @@ impl IncidentsAPI {
68226846
/// Retrieve a list of all postmortem templates for incidents.
68236847
pub async fn list_incident_postmortem_templates_with_http_info(
68246848
&self,
6849+
params: ListIncidentPostmortemTemplatesOptionalParams,
68256850
) -> Result<
68266851
datadog::ResponseContent<crate::datadogV2::model::PostmortemTemplatesResponse>,
68276852
datadog::Error<ListIncidentPostmortemTemplatesError>,
@@ -6837,6 +6862,10 @@ impl IncidentsAPI {
68376862
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
68386863
}
68396864

6865+
// unbox and build optional parameters
6866+
let filter_incident_type = params.filter_incident_type;
6867+
let sort = params.sort;
6868+
68406869
let local_client = &self.client;
68416870

68426871
let local_uri_str = format!(
@@ -6846,6 +6875,15 @@ impl IncidentsAPI {
68466875
let mut local_req_builder =
68476876
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
68486877

6878+
if let Some(ref local_query_param) = filter_incident_type {
6879+
local_req_builder = local_req_builder
6880+
.query(&[("filter[incident-type]", &local_query_param.to_string())]);
6881+
};
6882+
if let Some(ref local_query_param) = sort {
6883+
local_req_builder =
6884+
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
6885+
};
6886+
68496887
// build headers
68506888
let mut headers = HeaderMap::new();
68516889
headers.insert("Accept", HeaderValue::from_static("application/json"));

src/datadogV2/model/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,6 +4648,22 @@ pub mod model_postmortem_template_data_response;
46484648
pub use self::model_postmortem_template_data_response::PostmortemTemplateDataResponse;
46494649
pub mod model_postmortem_template_attributes_response;
46504650
pub use self::model_postmortem_template_attributes_response::PostmortemTemplateAttributesResponse;
4651+
pub mod model_confluence_postmortem_settings;
4652+
pub use self::model_confluence_postmortem_settings::ConfluencePostmortemSettings;
4653+
pub mod model_google_docs_postmortem_settings;
4654+
pub use self::model_google_docs_postmortem_settings::GoogleDocsPostmortemSettings;
4655+
pub mod model_postmortem_template_location;
4656+
pub use self::model_postmortem_template_location::PostmortemTemplateLocation;
4657+
pub mod model_postmortem_template_response_relationships;
4658+
pub use self::model_postmortem_template_response_relationships::PostmortemTemplateResponseRelationships;
4659+
pub mod model_postmortem_template_incident_type_relationship;
4660+
pub use self::model_postmortem_template_incident_type_relationship::PostmortemTemplateIncidentTypeRelationship;
4661+
pub mod model_postmortem_template_incident_type_relationship_data;
4662+
pub use self::model_postmortem_template_incident_type_relationship_data::PostmortemTemplateIncidentTypeRelationshipData;
4663+
pub mod model_postmortem_template_user_relationship;
4664+
pub use self::model_postmortem_template_user_relationship::PostmortemTemplateUserRelationship;
4665+
pub mod model_postmortem_template_user_relationship_data;
4666+
pub use self::model_postmortem_template_user_relationship_data::PostmortemTemplateUserRelationshipData;
46514667
pub mod model_postmortem_template_type;
46524668
pub use self::model_postmortem_template_type::PostmortemTemplateType;
46534669
pub mod model_postmortem_template_request;
@@ -4656,6 +4672,8 @@ pub mod model_postmortem_template_data_request;
46564672
pub use self::model_postmortem_template_data_request::PostmortemTemplateDataRequest;
46574673
pub mod model_postmortem_template_attributes_request;
46584674
pub use self::model_postmortem_template_attributes_request::PostmortemTemplateAttributesRequest;
4675+
pub mod model_postmortem_template_create_relationships;
4676+
pub use self::model_postmortem_template_create_relationships::PostmortemTemplateCreateRelationships;
46594677
pub mod model_postmortem_template_response;
46604678
pub use self::model_postmortem_template_response::PostmortemTemplateResponse;
46614679
pub mod model_incident_type_list_response;

0 commit comments

Comments
 (0)