v1_synthetics_CreateSyntheticsAPITest_2472747642/
v1_synthetics_CreateSyntheticsAPITest_2472747642.rs1use datadog_api_client::datadog;
4use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
5use datadog_api_client::datadogV1::model::SyntheticsAPITest;
6use datadog_api_client::datadogV1::model::SyntheticsAPITestConfig;
7use datadog_api_client::datadogV1::model::SyntheticsAPITestType;
8use datadog_api_client::datadogV1::model::SyntheticsAssertion;
9use datadog_api_client::datadogV1::model::SyntheticsAssertionOperator;
10use datadog_api_client::datadogV1::model::SyntheticsAssertionTarget;
11use datadog_api_client::datadogV1::model::SyntheticsAssertionTargetValue;
12use datadog_api_client::datadogV1::model::SyntheticsAssertionType;
13use datadog_api_client::datadogV1::model::SyntheticsTestDetailsSubType;
14use datadog_api_client::datadogV1::model::SyntheticsTestOptions;
15use datadog_api_client::datadogV1::model::SyntheticsTestOptionsRetry;
16use datadog_api_client::datadogV1::model::SyntheticsTestRequest;
17
18#[tokio::main]
19async fn main() {
20 let body = SyntheticsAPITest::new(
21 SyntheticsAPITestConfig::new()
22 .assertions(vec![
23 SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
24 SyntheticsAssertionTarget::new(
25 SyntheticsAssertionOperator::IS,
26 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
27 "message".to_string(),
28 ),
29 SyntheticsAssertionType::RECEIVED_MESSAGE,
30 ),
31 )),
32 SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
33 SyntheticsAssertionTarget::new(
34 SyntheticsAssertionOperator::LESS_THAN,
35 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
36 2000.0 as f64,
37 ),
38 SyntheticsAssertionType::RESPONSE_TIME,
39 ),
40 )),
41 ])
42 .config_variables(vec![])
43 .request(
44 SyntheticsTestRequest::new()
45 .message("message".to_string())
46 .url("ws://datadoghq.com".to_string()),
47 ),
48 vec!["aws:us-east-2".to_string()],
49 "BDD test payload: synthetics_api_test_websocket_payload.json".to_string(),
50 "Example-Synthetic".to_string(),
51 SyntheticsTestOptions::new()
52 .accept_self_signed(false)
53 .allow_insecure(true)
54 .follow_redirects(true)
55 .min_failure_duration(10)
56 .min_location_failed(1)
57 .monitor_name("Example-Synthetic".to_string())
58 .monitor_priority(5)
59 .retry(
60 SyntheticsTestOptionsRetry::new()
61 .count(3)
62 .interval(10.0 as f64),
63 )
64 .tick_every(60),
65 SyntheticsAPITestType::API,
66 )
67 .subtype(SyntheticsTestDetailsSubType::WEBSOCKET)
68 .tags(vec!["testing:api".to_string()]);
69 let configuration = datadog::Configuration::new();
70 let api = SyntheticsAPI::with_config(configuration);
71 let resp = api.create_synthetics_api_test(body).await;
72 if let Ok(value) = resp {
73 println!("{:#?}", value);
74 } else {
75 println!("{:#?}", resp.unwrap_err());
76 }
77}