v1_synthetics_CreateGlobalVariable_3397718516/
v1_synthetics_CreateGlobalVariable_3397718516.rs

1// Create a TOTP global variable returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
4use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableOptions;
5use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableRequest;
6use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableTOTPParameters;
7use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableValue;
8
9#[tokio::main]
10async fn main() {
11    let body = SyntheticsGlobalVariableRequest::new(
12        "".to_string(),
13        "GLOBAL_VARIABLE_TOTP_PAYLOAD_EXAMPLESYNTHETIC".to_string(),
14        vec![],
15    )
16    .is_totp(true)
17    .value(
18        SyntheticsGlobalVariableValue::new()
19            .options(
20                SyntheticsGlobalVariableOptions::new().totp_parameters(
21                    SyntheticsGlobalVariableTOTPParameters::new()
22                        .digits(6)
23                        .refresh_interval(30),
24                ),
25            )
26            .secure(false)
27            .value("".to_string()),
28    );
29    let configuration = datadog::Configuration::new();
30    let api = SyntheticsAPI::with_config(configuration);
31    let resp = api.create_global_variable(body).await;
32    if let Ok(value) = resp {
33        println!("{:#?}", value);
34    } else {
35        println!("{:#?}", resp.unwrap_err());
36    }
37}