v2_security_monitoring_CreateCustomFramework/
v2_security-monitoring_CreateCustomFramework.rs

1// Create a custom framework returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
4use datadog_api_client::datadogV2::model::CreateCustomFrameworkRequest;
5use datadog_api_client::datadogV2::model::CustomFrameworkControl;
6use datadog_api_client::datadogV2::model::CustomFrameworkData;
7use datadog_api_client::datadogV2::model::CustomFrameworkDataAttributes;
8use datadog_api_client::datadogV2::model::CustomFrameworkRequirement;
9use datadog_api_client::datadogV2::model::CustomFrameworkType;
10
11#[tokio::main]
12async fn main() {
13    let body = CreateCustomFrameworkRequest::new(CustomFrameworkData::new(
14        CustomFrameworkDataAttributes::new(
15            "create-framework-new".to_string(),
16            "name".to_string(),
17            vec![CustomFrameworkRequirement::new(
18                vec![CustomFrameworkControl::new(
19                    "control".to_string(),
20                    vec!["def-000-be9".to_string()],
21                )],
22                "requirement".to_string(),
23            )],
24            "10".to_string(),
25        )
26        .icon_url("test-url".to_string()),
27        CustomFrameworkType::CUSTOM_FRAMEWORK,
28    ));
29    let configuration = datadog::Configuration::new();
30    let api = SecurityMonitoringAPI::with_config(configuration);
31    let resp = api.create_custom_framework(body).await;
32    if let Ok(value) = resp {
33        println!("{:#?}", value);
34    } else {
35        println!("{:#?}", resp.unwrap_err());
36    }
37}