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