v1_synthetics_CreateSyntheticsAPITest_1072503741/
v1_synthetics_CreateSyntheticsAPITest_1072503741.rs1use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
4use datadog_api_client::datadogV1::model::SyntheticsAPITest;
5use datadog_api_client::datadogV1::model::SyntheticsAPITestConfig;
6use datadog_api_client::datadogV1::model::SyntheticsAPITestType;
7use datadog_api_client::datadogV1::model::SyntheticsAssertion;
8use datadog_api_client::datadogV1::model::SyntheticsAssertionOperator;
9use datadog_api_client::datadogV1::model::SyntheticsAssertionTarget;
10use datadog_api_client::datadogV1::model::SyntheticsAssertionTargetValue;
11use datadog_api_client::datadogV1::model::SyntheticsAssertionType;
12use datadog_api_client::datadogV1::model::SyntheticsTestDetailsSubType;
13use datadog_api_client::datadogV1::model::SyntheticsTestOptions;
14use datadog_api_client::datadogV1::model::SyntheticsTestRequest;
15use datadog_api_client::datadogV1::model::SyntheticsTestRequestPort;
16
17#[tokio::main]
18async fn main() {
19 let body = SyntheticsAPITest::new(
20 SyntheticsAPITestConfig::new()
21 .assertions(vec![SyntheticsAssertion::SyntheticsAssertionTarget(
22 Box::new(SyntheticsAssertionTarget::new(
23 SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
24 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
25 10.0 as f64,
26 ),
27 SyntheticsAssertionType::CERTIFICATE,
28 )),
29 )])
30 .request(
31 SyntheticsTestRequest::new()
32 .host("datadoghq.com".to_string())
33 .port(
34 SyntheticsTestRequestPort::SyntheticsTestRequestVariablePort(
35 "{{ DATADOG_PORT }}".to_string(),
36 ),
37 ),
38 ),
39 vec!["aws:us-east-2".to_string()],
40 "BDD test payload: synthetics_api_ssl_test_payload.json".to_string(),
41 "Example-Synthetic".to_string(),
42 SyntheticsTestOptions::new()
43 .accept_self_signed(true)
44 .check_certificate_revocation(true)
45 .disable_aia_intermediate_fetching(true)
46 .tick_every(60),
47 SyntheticsAPITestType::API,
48 )
49 .subtype(SyntheticsTestDetailsSubType::SSL)
50 .tags(vec!["testing:api".to_string()]);
51 let configuration = datadog::Configuration::new();
52 let api = SyntheticsAPI::with_config(configuration);
53 let resp = api.create_synthetics_api_test(body).await;
54 if let Ok(value) = resp {
55 println!("{:#?}", value);
56 } else {
57 println!("{:#?}", resp.unwrap_err());
58 }
59}