v2_gcp_integration_CreateGCPSTSAccount_2597004741/
v2_gcp-integration_CreateGCPSTSAccount_2597004741.rs

1// Create a new entry for your service account with security command center
2// enabled returns "OK" response
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::GCPSTSServiceAccountCreateRequest;
7use datadog_api_client::datadogV2::model::GCPSTSServiceAccountData;
8use datadog_api_client::datadogV2::model::GCPServiceAccountType;
9
10#[tokio::main]
11async fn main() {
12    let body = GCPSTSServiceAccountCreateRequest::new().data(
13        GCPSTSServiceAccountData::new()
14            .attributes(
15                GCPSTSServiceAccountAttributes::new()
16                    .client_email(
17                        "Test-252bf553ef04b351@test-project.iam.gserviceaccount.com".to_string(),
18                    )
19                    .host_filters(vec![])
20                    .is_resource_change_collection_enabled(true)
21                    .is_security_command_center_enabled(true),
22            )
23            .type_(GCPServiceAccountType::GCP_SERVICE_ACCOUNT),
24    );
25    let configuration = datadog::Configuration::new();
26    let api = GCPIntegrationAPI::with_config(configuration);
27    let resp = api.create_gcpsts_account(body).await;
28    if let Ok(value) = resp {
29        println!("{:#?}", value);
30    } else {
31        println!("{:#?}", resp.unwrap_err());
32    }
33}