v1_synthetics_CreateSyntheticsBrowserTest/
v1_synthetics_CreateSyntheticsBrowserTest.rs1use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
4use datadog_api_client::datadogV1::model::SyntheticsBrowserTest;
5use datadog_api_client::datadogV1::model::SyntheticsBrowserTestConfig;
6use datadog_api_client::datadogV1::model::SyntheticsBrowserTestType;
7use datadog_api_client::datadogV1::model::SyntheticsBrowserVariable;
8use datadog_api_client::datadogV1::model::SyntheticsBrowserVariableType;
9use datadog_api_client::datadogV1::model::SyntheticsConfigVariable;
10use datadog_api_client::datadogV1::model::SyntheticsConfigVariableType;
11use datadog_api_client::datadogV1::model::SyntheticsStep;
12use datadog_api_client::datadogV1::model::SyntheticsStepType;
13use datadog_api_client::datadogV1::model::SyntheticsTestOptions;
14use datadog_api_client::datadogV1::model::SyntheticsTestOptionsRetry;
15use datadog_api_client::datadogV1::model::SyntheticsTestRequest;
16use std::collections::BTreeMap;
17
18#[tokio::main]
19async fn main() {
20 let body = SyntheticsBrowserTest::new(
21 SyntheticsBrowserTestConfig::new(
22 vec![],
23 SyntheticsTestRequest::new()
24 .method("GET".to_string())
25 .url("https://datadoghq.com".to_string()),
26 )
27 .config_variables(vec![SyntheticsConfigVariable::new(
28 "PROPERTY".to_string(),
29 SyntheticsConfigVariableType::TEXT,
30 )
31 .example("content-type".to_string())
32 .pattern("content-type".to_string())
33 .secure(true)])
34 .set_cookie("name:test".to_string())
35 .variables(vec![SyntheticsBrowserVariable::new(
36 "TEST_VARIABLE".to_string(),
37 SyntheticsBrowserVariableType::TEXT,
38 )
39 .example("secret".to_string())
40 .pattern("secret".to_string())
41 .secure(true)]),
42 vec!["aws:us-east-2".to_string()],
43 "Test message".to_string(),
44 "Example-Synthetic".to_string(),
45 SyntheticsTestOptions::new()
46 .accept_self_signed(false)
47 .allow_insecure(true)
48 .device_ids(vec!["chrome.laptop_large".to_string()])
49 .disable_cors(true)
50 .enable_profiling(true)
51 .enable_security_testing(true)
52 .follow_redirects(true)
53 .min_failure_duration(10)
54 .min_location_failed(1)
55 .no_screenshot(true)
56 .retry(
57 SyntheticsTestOptionsRetry::new()
58 .count(2)
59 .interval(10.0 as f64),
60 )
61 .tick_every(300),
62 SyntheticsBrowserTestType::BROWSER,
63 )
64 .steps(vec![SyntheticsStep::new()
65 .allow_failure(false)
66 .always_execute(true)
67 .exit_if_succeed(true)
68 .is_critical(true)
69 .name("Refresh page".to_string())
70 .params(BTreeMap::new())
71 .type_(SyntheticsStepType::REFRESH)])
72 .tags(vec!["testing:browser".to_string()]);
73 let configuration = datadog::Configuration::new();
74 let api = SyntheticsAPI::with_config(configuration);
75 let resp = api.create_synthetics_browser_test(body).await;
76 if let Ok(value) = resp {
77 println!("{:#?}", value);
78 } else {
79 println!("{:#?}", resp.unwrap_err());
80 }
81}