v2_ip_allowlist_UpdateIPAllowlist/
v2_ip-allowlist_UpdateIPAllowlist.rs

1// Update IP Allowlist returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_ip_allowlist::IPAllowlistAPI;
4use datadog_api_client::datadogV2::model::IPAllowlistAttributes;
5use datadog_api_client::datadogV2::model::IPAllowlistData;
6use datadog_api_client::datadogV2::model::IPAllowlistEntry;
7use datadog_api_client::datadogV2::model::IPAllowlistEntryAttributes;
8use datadog_api_client::datadogV2::model::IPAllowlistEntryData;
9use datadog_api_client::datadogV2::model::IPAllowlistEntryType;
10use datadog_api_client::datadogV2::model::IPAllowlistType;
11use datadog_api_client::datadogV2::model::IPAllowlistUpdateRequest;
12
13#[tokio::main]
14async fn main() {
15    let body = IPAllowlistUpdateRequest::new(
16        IPAllowlistData::new(IPAllowlistType::IP_ALLOWLIST).attributes(
17            IPAllowlistAttributes::new()
18                .enabled(false)
19                .entries(vec![IPAllowlistEntry::new(
20                    IPAllowlistEntryData::new(IPAllowlistEntryType::IP_ALLOWLIST_ENTRY).attributes(
21                        IPAllowlistEntryAttributes::new()
22                            .cidr_block("127.0.0.1".to_string())
23                            .note("Example-IP-Allowlist".to_string()),
24                    ),
25                )]),
26        ),
27    );
28    let configuration = datadog::Configuration::new();
29    let api = IPAllowlistAPI::with_config(configuration);
30    let resp = api.update_ip_allowlist(body).await;
31    if let Ok(value) = resp {
32        println!("{:#?}", value);
33    } else {
34        println!("{:#?}", resp.unwrap_err());
35    }
36}