v2_gcp_integration_UpdateGCPSTSAccount_3205636354/
v2_gcp-integration_UpdateGCPSTSAccount_3205636354.rs

1// Update STS Service Account returns "OK" response with enable resource
2// collection turned on
3use datadog_api_client::datadog;
4use datadog_api_client::datadogV2::api_gcp_integration::GCPIntegrationAPI;
5use datadog_api_client::datadogV2::model::GCPSTSServiceAccountAttributes;
6use datadog_api_client::datadogV2::model::GCPSTSServiceAccountUpdateRequest;
7use datadog_api_client::datadogV2::model::GCPSTSServiceAccountUpdateRequestData;
8use datadog_api_client::datadogV2::model::GCPServiceAccountType;
9
10#[tokio::main]
11async fn main() {
12    // there is a valid "gcp_sts_account" in the system
13    let gcp_sts_account_data_id = std::env::var("GCP_STS_ACCOUNT_DATA_ID").unwrap();
14    let body = GCPSTSServiceAccountUpdateRequest::new().data(
15        GCPSTSServiceAccountUpdateRequestData::new()
16            .attributes(
17                GCPSTSServiceAccountAttributes::new()
18                    .client_email("Test-252bf553ef04b351@example.com".to_string())
19                    .resource_collection_enabled(true),
20            )
21            .id(gcp_sts_account_data_id.clone())
22            .type_(GCPServiceAccountType::GCP_SERVICE_ACCOUNT),
23    );
24    let configuration = datadog::Configuration::new();
25    let api = GCPIntegrationAPI::with_config(configuration);
26    let resp = api
27        .update_gcpsts_account(gcp_sts_account_data_id.clone(), body)
28        .await;
29    if let Ok(value) = resp {
30        println!("{:#?}", value);
31    } else {
32        println!("{:#?}", resp.unwrap_err());
33    }
34}