|
| 1 | +// Update a governance control returns "OK" response |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV2::api_governance_controls::GovernanceControlsAPI; |
| 4 | +use datadog_api_client::datadogV2::model::GovernanceControlResourceType; |
| 5 | +use datadog_api_client::datadogV2::model::GovernanceControlUpdateAttributes; |
| 6 | +use datadog_api_client::datadogV2::model::GovernanceControlUpdateData; |
| 7 | +use datadog_api_client::datadogV2::model::GovernanceControlUpdateRequest; |
| 8 | + |
| 9 | +#[tokio::main] |
| 10 | +async fn main() { |
| 11 | + let body = GovernanceControlUpdateRequest::new( |
| 12 | + GovernanceControlUpdateData::new(GovernanceControlResourceType::GOVERNANCE_CONTROL) |
| 13 | + .attributes( |
| 14 | + GovernanceControlUpdateAttributes::new() |
| 15 | + .detection_frequency("daily".to_string()) |
| 16 | + .mitigation_type("revoke_api_key".to_string()) |
| 17 | + .name("Unused API Keys".to_string()) |
| 18 | + .notification_frequency("daily".to_string()) |
| 19 | + .notification_type("slack".to_string()), |
| 20 | + ) |
| 21 | + .id("0d4e6f8a-1b2c-3d4e-5f6a-7b8c9d0e1f2a".to_string()), |
| 22 | + ); |
| 23 | + let mut configuration = datadog::Configuration::new(); |
| 24 | + configuration.set_unstable_operation_enabled("v2.UpdateGovernanceControl", true); |
| 25 | + let api = GovernanceControlsAPI::with_config(configuration); |
| 26 | + let resp = api |
| 27 | + .update_governance_control("detection_type".to_string(), body) |
| 28 | + .await; |
| 29 | + if let Ok(value) = resp { |
| 30 | + println!("{:#?}", value); |
| 31 | + } else { |
| 32 | + println!("{:#?}", resp.unwrap_err()); |
| 33 | + } |
| 34 | +} |
0 commit comments