1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Edit a global variable returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableAttributes;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableParseTestOptions;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableParseTestOptionsType;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableParserType;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableRequest;
use datadog_api_client::datadogV1::model::SyntheticsGlobalVariableValue;
use datadog_api_client::datadogV1::model::SyntheticsVariableParser;

#[tokio::main]
async fn main() {
    let body = SyntheticsGlobalVariableRequest::new(
        "Example description".to_string(),
        "MY_VARIABLE".to_string(),
        vec!["team:front".to_string(), "test:workflow-1".to_string()],
    )
    .attributes(
        SyntheticsGlobalVariableAttributes::new()
            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()]),
    )
    .parse_test_options(
        SyntheticsGlobalVariableParseTestOptions::new(
            SyntheticsGlobalVariableParseTestOptionsType::HTTP_BODY,
        )
        .field("content-type".to_string())
        .local_variable_name("LOCAL_VARIABLE".to_string())
        .parser(
            SyntheticsVariableParser::new(SyntheticsGlobalVariableParserType::REGEX)
                .value(".*".to_string()),
        ),
    )
    .parse_test_public_id("abc-def-123".to_string())
    .value(
        SyntheticsGlobalVariableValue::new()
            .secure(true)
            .value("value".to_string()),
    );
    let configuration = datadog::Configuration::new();
    let api = SyntheticsAPI::with_config(configuration);
    let resp = api
        .edit_global_variable("variable_id".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}