v2_incidents_UpdateIncidentAttachments/
v2_incidents_UpdateIncidentAttachments.rs

1// Create, update, and delete incident attachments returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
4use datadog_api_client::datadogV2::api_incidents::UpdateIncidentAttachmentsOptionalParams;
5use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttachmentType;
6use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributes;
7use datadog_api_client::datadogV2::model::IncidentAttachmentLinkAttributesAttachmentObject;
8use datadog_api_client::datadogV2::model::IncidentAttachmentPostmortemAttachmentType;
9use datadog_api_client::datadogV2::model::IncidentAttachmentPostmortemAttributes;
10use datadog_api_client::datadogV2::model::IncidentAttachmentType;
11use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateAttributes;
12use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateData;
13use datadog_api_client::datadogV2::model::IncidentAttachmentUpdateRequest;
14use datadog_api_client::datadogV2::model::IncidentAttachmentsPostmortemAttributesAttachmentObject;
15
16#[tokio::main]
17async fn main() {
18    let body = IncidentAttachmentUpdateRequest::new(vec![
19        IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS)
20            .attributes(
21                IncidentAttachmentUpdateAttributes::IncidentAttachmentPostmortemAttributes(
22                    Box::new(IncidentAttachmentPostmortemAttributes::new(
23                        IncidentAttachmentsPostmortemAttributesAttachmentObject::new(
24                            "https://app.datadoghq.com/notebook/123".to_string(),
25                            "Postmortem IR-123".to_string(),
26                        ),
27                        IncidentAttachmentPostmortemAttachmentType::POSTMORTEM,
28                    )),
29                ),
30            )
31            .id("00000000-abcd-0002-0000-000000000000".to_string()),
32        IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS).attributes(
33            IncidentAttachmentUpdateAttributes::IncidentAttachmentLinkAttributes(Box::new(
34                IncidentAttachmentLinkAttributes::new(
35                    IncidentAttachmentLinkAttributesAttachmentObject::new(
36                        "https://www.example.com/webstore-failure-runbook".to_string(),
37                        "Runbook for webstore service failures".to_string(),
38                    ),
39                    IncidentAttachmentLinkAttachmentType::LINK,
40                ),
41            )),
42        ),
43        IncidentAttachmentUpdateData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS)
44            .id("00000000-abcd-0003-0000-000000000000".to_string()),
45    ]);
46    let mut configuration = datadog::Configuration::new();
47    configuration.set_unstable_operation_enabled("v2.UpdateIncidentAttachments", true);
48    let api = IncidentsAPI::with_config(configuration);
49    let resp = api
50        .update_incident_attachments(
51            "incident_id".to_string(),
52            body,
53            UpdateIncidentAttachmentsOptionalParams::default(),
54        )
55        .await;
56    if let Ok(value) = resp {
57        println!("{:#?}", value);
58    } else {
59        println!("{:#?}", resp.unwrap_err());
60    }
61}