v2_incidents_UpdateIncidentNotificationTemplate/
v2_incidents_UpdateIncidentNotificationTemplate.rs

1// Update incident notification template returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
4use datadog_api_client::datadogV2::api_incidents::UpdateIncidentNotificationTemplateOptionalParams;
5use datadog_api_client::datadogV2::model::IncidentNotificationTemplateType;
6use datadog_api_client::datadogV2::model::IncidentNotificationTemplateUpdateAttributes;
7use datadog_api_client::datadogV2::model::IncidentNotificationTemplateUpdateData;
8use datadog_api_client::datadogV2::model::PatchIncidentNotificationTemplateRequest;
9
10#[tokio::main]
11async fn main() {
12    // there is a valid "notification_template" in the system
13    let notification_template_data_id =
14        uuid::Uuid::parse_str(&std::env::var("NOTIFICATION_TEMPLATE_DATA_ID").unwrap())
15            .expect("Invalid UUID");
16    let body = PatchIncidentNotificationTemplateRequest::new(
17        IncidentNotificationTemplateUpdateData::new(
18            notification_template_data_id.clone(),
19            IncidentNotificationTemplateType::NOTIFICATION_TEMPLATES,
20        )
21        .attributes(
22            IncidentNotificationTemplateUpdateAttributes::new()
23                .category("update".to_string())
24                .content(
25                    r#"Incident Status Update:
26
27Title: Sample Incident Title
28New Status: resolved
29Severity: SEV-2
30Services: web-service, database-service
31Commander: John Doe
32
33For more details, visit the incident page."#
34                        .to_string(),
35                )
36                .name("Example-Incident".to_string())
37                .subject("Incident Update: Sample Incident Title - resolved".to_string()),
38        ),
39    );
40    let mut configuration = datadog::Configuration::new();
41    configuration.set_unstable_operation_enabled("v2.UpdateIncidentNotificationTemplate", true);
42    let api = IncidentsAPI::with_config(configuration);
43    let resp = api
44        .update_incident_notification_template(
45            notification_template_data_id.clone(),
46            body,
47            UpdateIncidentNotificationTemplateOptionalParams::default(),
48        )
49        .await;
50    if let Ok(value) = resp {
51        println!("{:#?}", value);
52    } else {
53        println!("{:#?}", resp.unwrap_err());
54    }
55}