SyntheticsTestRequest

Struct SyntheticsTestRequest 

Source
#[non_exhaustive]
pub struct SyntheticsTestRequest {
Show 35 fields pub allow_insecure: Option<bool>, pub basic_auth: Option<SyntheticsBasicAuth>, pub body: Option<String>, pub body_type: Option<SyntheticsTestRequestBodyType>, pub call_type: Option<SyntheticsTestCallType>, pub certificate: Option<SyntheticsTestRequestCertificate>, pub certificate_domains: Option<Vec<String>>, pub check_certificate_revocation: Option<bool>, pub compressed_json_descriptor: Option<String>, pub compressed_proto_file: Option<String>, pub disable_aia_intermediate_fetching: Option<bool>, pub dns_server: Option<String>, pub dns_server_port: Option<SyntheticsTestRequestDNSServerPort>, pub files: Option<Vec<SyntheticsTestRequestBodyFile>>, pub follow_redirects: Option<bool>, pub form: Option<BTreeMap<String, String>>, pub headers: Option<BTreeMap<String, String>>, pub host: Option<String>, pub http_version: Option<SyntheticsTestOptionsHTTPVersion>, pub is_message_base64_encoded: Option<bool>, pub message: Option<String>, pub metadata: Option<BTreeMap<String, String>>, pub method: Option<String>, pub no_saving_response_body: Option<bool>, pub number_of_packets: Option<i32>, pub persist_cookies: Option<bool>, pub port: Option<SyntheticsTestRequestPort>, pub proxy: Option<SyntheticsTestRequestProxy>, pub query: Option<BTreeMap<String, Value>>, pub servername: Option<String>, pub service: Option<String>, pub should_track_hops: Option<bool>, pub timeout: Option<f64>, pub url: Option<String>, pub additional_properties: BTreeMap<String, Value>, /* private fields */
}
Expand description

Object describing the Synthetic test request.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§allow_insecure: Option<bool>

Allows loading insecure content for an HTTP request in a multistep test step.

§basic_auth: Option<SyntheticsBasicAuth>

Object to handle basic authentication when performing the test.

§body: Option<String>

Body to include in the test.

§body_type: Option<SyntheticsTestRequestBodyType>

Type of the request body.

§call_type: Option<SyntheticsTestCallType>

The type of gRPC call to perform.

§certificate: Option<SyntheticsTestRequestCertificate>

Client certificate to use when performing the test request.

§certificate_domains: Option<Vec<String>>

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

§check_certificate_revocation: Option<bool>

Check for certificate revocation.

§compressed_json_descriptor: Option<String>

A protobuf JSON descriptor that needs to be gzipped first then base64 encoded.

§compressed_proto_file: Option<String>

A protobuf file that needs to be gzipped first then base64 encoded.

§disable_aia_intermediate_fetching: Option<bool>

Disable fetching intermediate certificates from AIA.

§dns_server: Option<String>

DNS server to use for DNS tests.

§dns_server_port: Option<SyntheticsTestRequestDNSServerPort>

DNS server port to use for DNS tests.

§files: Option<Vec<SyntheticsTestRequestBodyFile>>

Files to be used as part of the request in the test. Only valid if bodyType is multipart/form-data.

§follow_redirects: Option<bool>

Specifies whether or not the request follows redirects.

§form: Option<BTreeMap<String, String>>

Form to be used as part of the request in the test. Only valid if bodyType is multipart/form-data.

§headers: Option<BTreeMap<String, String>>

Headers to include when performing the test.

§host: Option<String>

Host name to perform the test with.

§http_version: Option<SyntheticsTestOptionsHTTPVersion>

HTTP version to use for a Synthetic test.

§is_message_base64_encoded: Option<bool>

Whether the message is base64 encoded.

§message: Option<String>

Message to send for UDP or WebSocket tests.

§metadata: Option<BTreeMap<String, String>>

Metadata to include when performing the gRPC test.

§method: Option<String>

Either the HTTP method/verb to use or a gRPC method available on the service set in the service field. Required if subtype is HTTP or if subtype is grpc and callType is unary.

§no_saving_response_body: Option<bool>

Determines whether or not to save the response body.

§number_of_packets: Option<i32>

Number of pings to use per test.

§persist_cookies: Option<bool>

Persist cookies across redirects.

§port: Option<SyntheticsTestRequestPort>

Port to use when performing the test.

§proxy: Option<SyntheticsTestRequestProxy>

The proxy to perform the test.

§query: Option<BTreeMap<String, Value>>

Query to use for the test.

§servername: Option<String>

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

§service: Option<String>

The gRPC service on which you want to perform the gRPC call.

§should_track_hops: Option<bool>

Turns on a traceroute probe to discover all gateways along the path to the host destination.

§timeout: Option<f64>

Timeout in seconds for the test.

§url: Option<String>

URL to perform the test with.

§additional_properties: BTreeMap<String, Value>

Implementations§

Source§

impl SyntheticsTestRequest

Source

pub fn new() -> SyntheticsTestRequest

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1072503741.rs (line 31)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsBrowserTest.rs (line 23)
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}
examples/v1_synthetics_CreateSyntheticsBrowserTest_2932742688.rs (line 24)
20async fn main() {
21    let body = SyntheticsBrowserTest::new(
22        SyntheticsBrowserTestConfig::new(
23            vec![],
24            SyntheticsTestRequest::new()
25                .certificate_domains(vec!["https://datadoghq.com".to_string()])
26                .method("GET".to_string())
27                .url("https://datadoghq.com".to_string()),
28        )
29        .config_variables(vec![SyntheticsConfigVariable::new(
30            "PROPERTY".to_string(),
31            SyntheticsConfigVariableType::TEXT,
32        )
33        .example("content-type".to_string())
34        .pattern("content-type".to_string())])
35        .set_cookie("name:test".to_string()),
36        vec!["aws:us-east-2".to_string()],
37        "Test message".to_string(),
38        "Example-Synthetic".to_string(),
39        SyntheticsTestOptions::new()
40            .accept_self_signed(false)
41            .allow_insecure(true)
42            .ci(SyntheticsTestCiOptions::new(
43                SyntheticsTestExecutionRule::SKIPPED,
44            ))
45            .device_ids(vec!["tablet".to_string()])
46            .disable_cors(true)
47            .disable_csp(true)
48            .follow_redirects(true)
49            .ignore_server_certificate_error(true)
50            .initial_navigation_timeout(200)
51            .min_failure_duration(10)
52            .min_location_failed(1)
53            .no_screenshot(true)
54            .retry(
55                SyntheticsTestOptionsRetry::new()
56                    .count(2)
57                    .interval(10.0 as f64),
58            )
59            .rum_settings(
60                SyntheticsBrowserTestRumSettings::new(true)
61                    .application_id("mockApplicationId".to_string())
62                    .client_token_id(12345),
63            )
64            .tick_every(300),
65        SyntheticsBrowserTestType::BROWSER,
66    )
67    .steps(vec![SyntheticsStep::new()
68        .allow_failure(false)
69        .is_critical(true)
70        .name("Refresh page".to_string())
71        .params(BTreeMap::new())
72        .type_(SyntheticsStepType::REFRESH)])
73    .tags(vec!["testing:browser".to_string()]);
74    let configuration = datadog::Configuration::new();
75    let api = SyntheticsAPI::with_config(configuration);
76    let resp = api.create_synthetics_browser_test(body).await;
77    if let Ok(value) = resp {
78        println!("{:#?}", value);
79    } else {
80        println!("{:#?}", resp.unwrap_err());
81    }
82}
examples/v1_synthetics_CreateSyntheticsAPITest_2472747642.rs (line 44)
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}
examples/v1_synthetics_CreateSyntheticsBrowserTest_397420811.rs (line 24)
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}
examples/v1_synthetics_CreateSyntheticsAPITest_3829801148.rs (line 45)
20async fn main() {
21    let body = SyntheticsAPITest::new(
22        SyntheticsAPITestConfig::new()
23            .assertions(vec![
24                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
25                    SyntheticsAssertionTarget::new(
26                        SyntheticsAssertionOperator::IS,
27                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
28                            "message".to_string(),
29                        ),
30                        SyntheticsAssertionType::RECEIVED_MESSAGE,
31                    ),
32                )),
33                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
34                    SyntheticsAssertionTarget::new(
35                        SyntheticsAssertionOperator::LESS_THAN,
36                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
37                            2000.0 as f64,
38                        ),
39                        SyntheticsAssertionType::RESPONSE_TIME,
40                    ),
41                )),
42            ])
43            .config_variables(vec![])
44            .request(
45                SyntheticsTestRequest::new()
46                    .host("https://datadoghq.com".to_string())
47                    .message("message".to_string())
48                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
49            ),
50        vec!["aws:us-east-2".to_string()],
51        "BDD test payload: synthetics_api_test_udp_payload.json".to_string(),
52        "Example-Synthetic".to_string(),
53        SyntheticsTestOptions::new()
54            .accept_self_signed(false)
55            .allow_insecure(true)
56            .follow_redirects(true)
57            .min_failure_duration(10)
58            .min_location_failed(1)
59            .monitor_name("Example-Synthetic".to_string())
60            .monitor_priority(5)
61            .retry(
62                SyntheticsTestOptionsRetry::new()
63                    .count(3)
64                    .interval(10.0 as f64),
65            )
66            .tick_every(60),
67        SyntheticsAPITestType::API,
68    )
69    .subtype(SyntheticsTestDetailsSubType::UDP)
70    .tags(vec!["testing:api".to_string()]);
71    let configuration = datadog::Configuration::new();
72    let api = SyntheticsAPI::with_config(configuration);
73    let resp = api.create_synthetics_api_test(body).await;
74    if let Ok(value) = resp {
75        println!("{:#?}", value);
76    } else {
77        println!("{:#?}", resp.unwrap_err());
78    }
79}
Source

pub fn allow_insecure(self, value: bool) -> Self

Source

pub fn basic_auth(self, value: SyntheticsBasicAuth) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (lines 41-46)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (lines 112-127)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
examples/v1_synthetics_CreateSyntheticsAPITest_960766374.rs (lines 126-143)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
85                            Box::new(
86                                SyntheticsAssertionJSONSchemaTarget::new(
87                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
91                                        .json_schema(
92                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
93                                        )
94                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
95                                ),
96                            ),
97                        ),
98                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
99                            Box::new(
100                                SyntheticsAssertionXPathTarget::new(
101                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
102                                    SyntheticsAssertionType::BODY,
103                                ).target(
104                                    SyntheticsAssertionXPathTargetTarget::new()
105                                        .operator("contains".to_string())
106                                        .target_value(
107                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
108                                                "0".to_string(),
109                                            ),
110                                        )
111                                        .x_path("target-xpath".to_string()),
112                                ),
113                            ),
114                        )
115                    ],
116                )
117                .config_variables(
118                    vec![
119                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
120                            .example("content-type".to_string())
121                            .pattern("content-type".to_string())
122                    ],
123                )
124                .request(
125                    SyntheticsTestRequest::new()
126                        .basic_auth(
127                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(
128                                Box::new(
129                                    SyntheticsBasicAuthOauthROP::new(
130                                        "https://datadog-token.com".to_string(),
131                                        "oauth-password".to_string(),
132                                        SyntheticsBasicAuthOauthTokenApiAuthentication::BODY,
133                                        SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
134                                        "oauth-usermame".to_string(),
135                                    )
136                                        .audience("audience".to_string())
137                                        .client_id("client-id".to_string())
138                                        .client_secret("client-secret".to_string())
139                                        .resource("resource".to_string())
140                                        .scope("yoyo".to_string()),
141                                ),
142                            ),
143                        )
144                        .certificate(
145                            SyntheticsTestRequestCertificate::new()
146                                .cert(
147                                    SyntheticsTestRequestCertificateItem::new()
148                                        .content("cert-content".to_string())
149                                        .filename("cert-filename".to_string())
150                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
151                                )
152                                .key(
153                                    SyntheticsTestRequestCertificateItem::new()
154                                        .content("key-content".to_string())
155                                        .filename("key-filename".to_string())
156                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
157                                ),
158                        )
159                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
160                        .method("GET".to_string())
161                        .proxy(
162                            SyntheticsTestRequestProxy::new(
163                                "https://datadoghq.com".to_string(),
164                            ).headers(BTreeMap::from([])),
165                        )
166                        .timeout(10.0 as f64)
167                        .url("https://datadoghq.com".to_string()),
168                ),
169            vec!["aws:us-east-2".to_string()],
170            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
171            "Example-Synthetic".to_string(),
172            SyntheticsTestOptions::new()
173                .accept_self_signed(false)
174                .allow_insecure(true)
175                .follow_redirects(true)
176                .min_failure_duration(10)
177                .min_location_failed(1)
178                .monitor_name("Example-Synthetic".to_string())
179                .monitor_priority(5)
180                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
181                .tick_every(60),
182            SyntheticsAPITestType::API,
183        )
184            .subtype(SyntheticsTestDetailsSubType::HTTP)
185            .tags(vec!["testing:api".to_string()]);
186    let configuration = datadog::Configuration::new();
187    let api = SyntheticsAPI::with_config(configuration);
188    let resp = api.create_synthetics_api_test(body).await;
189    if let Ok(value) = resp {
190        println!("{:#?}", value);
191    } else {
192        println!("{:#?}", resp.unwrap_err());
193    }
194}
examples/v1_synthetics_CreateSyntheticsAPITest_1717840259.rs (lines 50-54)
35async fn main() {
36    let body = SyntheticsAPITest::new(
37        SyntheticsAPITestConfig::new().steps(vec![
38            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
39                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
40                    SyntheticsAssertionTarget::new(
41                        SyntheticsAssertionOperator::IS,
42                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
43                            200.0 as f64,
44                        ),
45                        SyntheticsAssertionType::STATUS_CODE,
46                    ),
47                ))],
48                "request is sent".to_string(),
49                SyntheticsTestRequest::new()
50                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
51                        SyntheticsBasicAuthWeb::new()
52                            .password("password".to_string())
53                            .username("username".to_string()),
54                    )))
55                    .method("GET".to_string())
56                    .url("https://httpbin.org/status/200".to_string()),
57                SyntheticsAPITestStepSubtype::HTTP,
58            ))),
59            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
60                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
61                    SyntheticsAssertionTarget::new(
62                        SyntheticsAssertionOperator::IS,
63                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
64                            200.0 as f64,
65                        ),
66                        SyntheticsAssertionType::STATUS_CODE,
67                    ),
68                ))],
69                "request is sent".to_string(),
70                SyntheticsTestRequest::new()
71                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
72                        SyntheticsBasicAuthWeb::new()
73                            .password("password".to_string())
74                            .type_(SyntheticsBasicAuthWebType::WEB)
75                            .username("username".to_string()),
76                    )))
77                    .method("GET".to_string())
78                    .url("https://httpbin.org/status/200".to_string()),
79                SyntheticsAPITestStepSubtype::HTTP,
80            ))),
81            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
82                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
83                    SyntheticsAssertionTarget::new(
84                        SyntheticsAssertionOperator::IS,
85                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
86                            200.0 as f64,
87                        ),
88                        SyntheticsAssertionType::STATUS_CODE,
89                    ),
90                ))],
91                "request is sent".to_string(),
92                SyntheticsTestRequest::new()
93                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthSigv4(Box::new(
94                        SyntheticsBasicAuthSigv4::new(
95                            "accessKey".to_string(),
96                            "secretKey".to_string(),
97                            SyntheticsBasicAuthSigv4Type::SIGV4,
98                        ),
99                    )))
100                    .method("GET".to_string())
101                    .url("https://httpbin.org/status/200".to_string()),
102                SyntheticsAPITestStepSubtype::HTTP,
103            ))),
104            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
105                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
106                    SyntheticsAssertionTarget::new(
107                        SyntheticsAssertionOperator::IS,
108                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
109                            200.0 as f64,
110                        ),
111                        SyntheticsAssertionType::STATUS_CODE,
112                    ),
113                ))],
114                "request is sent".to_string(),
115                SyntheticsTestRequest::new()
116                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthNTLM(Box::new(
117                        SyntheticsBasicAuthNTLM::new(SyntheticsBasicAuthNTLMType::NTLM),
118                    )))
119                    .method("GET".to_string())
120                    .url("https://httpbin.org/status/200".to_string()),
121                SyntheticsAPITestStepSubtype::HTTP,
122            ))),
123            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
124                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
125                    SyntheticsAssertionTarget::new(
126                        SyntheticsAssertionOperator::IS,
127                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
128                            200.0 as f64,
129                        ),
130                        SyntheticsAssertionType::STATUS_CODE,
131                    ),
132                ))],
133                "request is sent".to_string(),
134                SyntheticsTestRequest::new()
135                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthDigest(Box::new(
136                        SyntheticsBasicAuthDigest::new(
137                            "password".to_string(),
138                            SyntheticsBasicAuthDigestType::DIGEST,
139                            "username".to_string(),
140                        ),
141                    )))
142                    .method("GET".to_string())
143                    .url("https://httpbin.org/status/200".to_string()),
144                SyntheticsAPITestStepSubtype::HTTP,
145            ))),
146            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
147                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
148                    SyntheticsAssertionTarget::new(
149                        SyntheticsAssertionOperator::IS,
150                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
151                            200.0 as f64,
152                        ),
153                        SyntheticsAssertionType::STATUS_CODE,
154                    ),
155                ))],
156                "request is sent".to_string(),
157                SyntheticsTestRequest::new()
158                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
159                        Box::new(SyntheticsBasicAuthOauthClient::new(
160                            "accessTokenUrl".to_string(),
161                            "clientId".to_string(),
162                            "clientSecret".to_string(),
163                            SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
164                            SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
165                        )),
166                    ))
167                    .method("GET".to_string())
168                    .url("https://httpbin.org/status/200".to_string()),
169                SyntheticsAPITestStepSubtype::HTTP,
170            ))),
171            SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
172                vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
173                    SyntheticsAssertionTarget::new(
174                        SyntheticsAssertionOperator::IS,
175                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
176                            200.0 as f64,
177                        ),
178                        SyntheticsAssertionType::STATUS_CODE,
179                    ),
180                ))],
181                "request is sent".to_string(),
182                SyntheticsTestRequest::new()
183                    .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(Box::new(
184                        SyntheticsBasicAuthOauthROP::new(
185                            "accessTokenUrl".to_string(),
186                            "password".to_string(),
187                            SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
188                            SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
189                            "username".to_string(),
190                        ),
191                    )))
192                    .method("GET".to_string())
193                    .url("https://httpbin.org/status/200".to_string()),
194                SyntheticsAPITestStepSubtype::HTTP,
195            ))),
196        ]),
197        vec!["aws:us-east-2".to_string()],
198        "BDD test payload: synthetics_api_test_multi_step_with_every_type_of_basic_auth.json"
199            .to_string(),
200        "Example-Synthetic".to_string(),
201        SyntheticsTestOptions::new().tick_every(60),
202        SyntheticsAPITestType::API,
203    )
204    .subtype(SyntheticsTestDetailsSubType::MULTI);
205    let configuration = datadog::Configuration::new();
206    let api = SyntheticsAPI::with_config(configuration);
207    let resp = api.create_synthetics_api_test(body).await;
208    if let Ok(value) = resp {
209        println!("{:#?}", value);
210    } else {
211        println!("{:#?}", resp.unwrap_err());
212    }
213}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (lines 170-185)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (lines 169-184)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
Source

pub fn body(self, value: String) -> Self

Source

pub fn body_type(self, value: SyntheticsTestRequestBodyType) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (line 47)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 128)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
Source

pub fn call_type(self, value: SyntheticsTestCallType) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (line 48)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 123)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn certificate(self, value: SyntheticsTestRequestCertificate) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (lines 49-53)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_UpdateAPITest.rs (lines 103-115)
31async fn main() {
32    // there is a valid "synthetics_api_test" in the system
33    let synthetics_api_test_public_id = std::env::var("SYNTHETICS_API_TEST_PUBLIC_ID").unwrap();
34    let body =
35        SyntheticsAPITest::new(
36            SyntheticsAPITestConfig::new()
37                .assertions(
38                    vec![
39                        SyntheticsAssertion::SyntheticsAssertionTarget(
40                            Box::new(
41                                SyntheticsAssertionTarget::new(
42                                    SyntheticsAssertionOperator::IS,
43                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
44                                        "text/html".to_string(),
45                                    ),
46                                    SyntheticsAssertionType::HEADER,
47                                ).property("{{ PROPERTY }}".to_string()),
48                            ),
49                        ),
50                        SyntheticsAssertion::SyntheticsAssertionTarget(
51                            Box::new(
52                                SyntheticsAssertionTarget::new(
53                                    SyntheticsAssertionOperator::LESS_THAN,
54                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
55                                        2000.0 as f64,
56                                    ),
57                                    SyntheticsAssertionType::RESPONSE_TIME,
58                                ),
59                            ),
60                        ),
61                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
62                            Box::new(
63                                SyntheticsAssertionJSONPathTarget::new(
64                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
65                                    SyntheticsAssertionType::BODY,
66                                ).target(
67                                    SyntheticsAssertionJSONPathTargetTarget::new()
68                                        .json_path("topKey".to_string())
69                                        .operator("isNot".to_string())
70                                        .target_value(
71                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
72                                                "0".to_string(),
73                                            ),
74                                        ),
75                                ),
76                            ),
77                        ),
78                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
79                            Box::new(
80                                SyntheticsAssertionJSONSchemaTarget::new(
81                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
82                                    SyntheticsAssertionType::BODY,
83                                ).target(
84                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
85                                        .json_schema(
86                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
87                                        )
88                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
89                                ),
90                            ),
91                        )
92                    ],
93                )
94                .config_variables(
95                    vec![
96                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
97                            .example("content-type".to_string())
98                            .pattern("content-type".to_string())
99                    ],
100                )
101                .request(
102                    SyntheticsTestRequest::new()
103                        .certificate(
104                            SyntheticsTestRequestCertificate::new()
105                                .cert(
106                                    SyntheticsTestRequestCertificateItem::new()
107                                        .filename("cert-filename".to_string())
108                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
109                                )
110                                .key(
111                                    SyntheticsTestRequestCertificateItem::new()
112                                        .filename("key-filename".to_string())
113                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
114                                ),
115                        )
116                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
117                        .method("GET".to_string())
118                        .timeout(10.0 as f64)
119                        .url("https://datadoghq.com".to_string()),
120                ),
121            vec!["aws:us-east-2".to_string()],
122            "BDD test payload: synthetics_api_test_payload.json".to_string(),
123            "Example-Synthetic-updated".to_string(),
124            SyntheticsTestOptions::new()
125                .accept_self_signed(false)
126                .allow_insecure(true)
127                .follow_redirects(true)
128                .min_failure_duration(10)
129                .min_location_failed(1)
130                .monitor_name("Test-TestSyntheticsAPITestLifecycle-1623076664".to_string())
131                .monitor_priority(5)
132                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
133                .tick_every(60),
134            SyntheticsAPITestType::API,
135        )
136            .status(SyntheticsTestPauseStatus::LIVE)
137            .subtype(SyntheticsTestDetailsSubType::HTTP)
138            .tags(vec!["testing:api".to_string()]);
139    let configuration = datadog::Configuration::new();
140    let api = SyntheticsAPI::with_config(configuration);
141    let resp = api
142        .update_api_test(synthetics_api_test_public_id.clone(), body)
143        .await;
144    if let Ok(value) = resp {
145        println!("{:#?}", value);
146    } else {
147        println!("{:#?}", resp.unwrap_err());
148    }
149}
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (lines 129-143)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
examples/v1_synthetics_CreateSyntheticsAPITest_960766374.rs (lines 144-158)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
85                            Box::new(
86                                SyntheticsAssertionJSONSchemaTarget::new(
87                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
91                                        .json_schema(
92                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
93                                        )
94                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
95                                ),
96                            ),
97                        ),
98                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
99                            Box::new(
100                                SyntheticsAssertionXPathTarget::new(
101                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
102                                    SyntheticsAssertionType::BODY,
103                                ).target(
104                                    SyntheticsAssertionXPathTargetTarget::new()
105                                        .operator("contains".to_string())
106                                        .target_value(
107                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
108                                                "0".to_string(),
109                                            ),
110                                        )
111                                        .x_path("target-xpath".to_string()),
112                                ),
113                            ),
114                        )
115                    ],
116                )
117                .config_variables(
118                    vec![
119                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
120                            .example("content-type".to_string())
121                            .pattern("content-type".to_string())
122                    ],
123                )
124                .request(
125                    SyntheticsTestRequest::new()
126                        .basic_auth(
127                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(
128                                Box::new(
129                                    SyntheticsBasicAuthOauthROP::new(
130                                        "https://datadog-token.com".to_string(),
131                                        "oauth-password".to_string(),
132                                        SyntheticsBasicAuthOauthTokenApiAuthentication::BODY,
133                                        SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
134                                        "oauth-usermame".to_string(),
135                                    )
136                                        .audience("audience".to_string())
137                                        .client_id("client-id".to_string())
138                                        .client_secret("client-secret".to_string())
139                                        .resource("resource".to_string())
140                                        .scope("yoyo".to_string()),
141                                ),
142                            ),
143                        )
144                        .certificate(
145                            SyntheticsTestRequestCertificate::new()
146                                .cert(
147                                    SyntheticsTestRequestCertificateItem::new()
148                                        .content("cert-content".to_string())
149                                        .filename("cert-filename".to_string())
150                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
151                                )
152                                .key(
153                                    SyntheticsTestRequestCertificateItem::new()
154                                        .content("key-content".to_string())
155                                        .filename("key-filename".to_string())
156                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
157                                ),
158                        )
159                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
160                        .method("GET".to_string())
161                        .proxy(
162                            SyntheticsTestRequestProxy::new(
163                                "https://datadoghq.com".to_string(),
164                            ).headers(BTreeMap::from([])),
165                        )
166                        .timeout(10.0 as f64)
167                        .url("https://datadoghq.com".to_string()),
168                ),
169            vec!["aws:us-east-2".to_string()],
170            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
171            "Example-Synthetic".to_string(),
172            SyntheticsTestOptions::new()
173                .accept_self_signed(false)
174                .allow_insecure(true)
175                .follow_redirects(true)
176                .min_failure_duration(10)
177                .min_location_failed(1)
178                .monitor_name("Example-Synthetic".to_string())
179                .monitor_priority(5)
180                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
181                .tick_every(60),
182            SyntheticsAPITestType::API,
183        )
184            .subtype(SyntheticsTestDetailsSubType::HTTP)
185            .tags(vec!["testing:api".to_string()]);
186    let configuration = datadog::Configuration::new();
187    let api = SyntheticsAPI::with_config(configuration);
188    let resp = api.create_synthetics_api_test(body).await;
189    if let Ok(value) = resp {
190        println!("{:#?}", value);
191    } else {
192        println!("{:#?}", resp.unwrap_err());
193    }
194}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (lines 186-200)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (lines 185-199)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
Source

pub fn certificate_domains(self, value: Vec<String>) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsBrowserTest_2932742688.rs (line 25)
20async fn main() {
21    let body = SyntheticsBrowserTest::new(
22        SyntheticsBrowserTestConfig::new(
23            vec![],
24            SyntheticsTestRequest::new()
25                .certificate_domains(vec!["https://datadoghq.com".to_string()])
26                .method("GET".to_string())
27                .url("https://datadoghq.com".to_string()),
28        )
29        .config_variables(vec![SyntheticsConfigVariable::new(
30            "PROPERTY".to_string(),
31            SyntheticsConfigVariableType::TEXT,
32        )
33        .example("content-type".to_string())
34        .pattern("content-type".to_string())])
35        .set_cookie("name:test".to_string()),
36        vec!["aws:us-east-2".to_string()],
37        "Test message".to_string(),
38        "Example-Synthetic".to_string(),
39        SyntheticsTestOptions::new()
40            .accept_self_signed(false)
41            .allow_insecure(true)
42            .ci(SyntheticsTestCiOptions::new(
43                SyntheticsTestExecutionRule::SKIPPED,
44            ))
45            .device_ids(vec!["tablet".to_string()])
46            .disable_cors(true)
47            .disable_csp(true)
48            .follow_redirects(true)
49            .ignore_server_certificate_error(true)
50            .initial_navigation_timeout(200)
51            .min_failure_duration(10)
52            .min_location_failed(1)
53            .no_screenshot(true)
54            .retry(
55                SyntheticsTestOptionsRetry::new()
56                    .count(2)
57                    .interval(10.0 as f64),
58            )
59            .rum_settings(
60                SyntheticsBrowserTestRumSettings::new(true)
61                    .application_id("mockApplicationId".to_string())
62                    .client_token_id(12345),
63            )
64            .tick_every(300),
65        SyntheticsBrowserTestType::BROWSER,
66    )
67    .steps(vec![SyntheticsStep::new()
68        .allow_failure(false)
69        .is_critical(true)
70        .name("Refresh page".to_string())
71        .params(BTreeMap::new())
72        .type_(SyntheticsStepType::REFRESH)])
73    .tags(vec!["testing:browser".to_string()]);
74    let configuration = datadog::Configuration::new();
75    let api = SyntheticsAPI::with_config(configuration);
76    let resp = api.create_synthetics_browser_test(body).await;
77    if let Ok(value) = resp {
78        println!("{:#?}", value);
79    } else {
80        println!("{:#?}", resp.unwrap_err());
81    }
82}
More examples
Hide additional examples
examples/v1_synthetics_UpdateBrowserTest.rs (line 54)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
Source

pub fn check_certificate_revocation(self, value: bool) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 160)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn compressed_json_descriptor(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (lines 124-126)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn compressed_proto_file(self, value: String) -> Self

Source

pub fn disable_aia_intermediate_fetching(self, value: bool) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 161)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn dns_server(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 190)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn dns_server_port(self, value: SyntheticsTestRequestDNSServerPort) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (lines 191-196)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn files(self, value: Vec<SyntheticsTestRequestBodyFile>) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (line 55)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (lines 144-152)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
Source

pub fn follow_redirects(self, value: bool) -> Self

Source

pub fn form(self, value: BTreeMap<String, String>) -> Self

Source

pub fn headers(self, value: BTreeMap<String, String>) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateAPITest.rs (line 116)
31async fn main() {
32    // there is a valid "synthetics_api_test" in the system
33    let synthetics_api_test_public_id = std::env::var("SYNTHETICS_API_TEST_PUBLIC_ID").unwrap();
34    let body =
35        SyntheticsAPITest::new(
36            SyntheticsAPITestConfig::new()
37                .assertions(
38                    vec![
39                        SyntheticsAssertion::SyntheticsAssertionTarget(
40                            Box::new(
41                                SyntheticsAssertionTarget::new(
42                                    SyntheticsAssertionOperator::IS,
43                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
44                                        "text/html".to_string(),
45                                    ),
46                                    SyntheticsAssertionType::HEADER,
47                                ).property("{{ PROPERTY }}".to_string()),
48                            ),
49                        ),
50                        SyntheticsAssertion::SyntheticsAssertionTarget(
51                            Box::new(
52                                SyntheticsAssertionTarget::new(
53                                    SyntheticsAssertionOperator::LESS_THAN,
54                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
55                                        2000.0 as f64,
56                                    ),
57                                    SyntheticsAssertionType::RESPONSE_TIME,
58                                ),
59                            ),
60                        ),
61                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
62                            Box::new(
63                                SyntheticsAssertionJSONPathTarget::new(
64                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
65                                    SyntheticsAssertionType::BODY,
66                                ).target(
67                                    SyntheticsAssertionJSONPathTargetTarget::new()
68                                        .json_path("topKey".to_string())
69                                        .operator("isNot".to_string())
70                                        .target_value(
71                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
72                                                "0".to_string(),
73                                            ),
74                                        ),
75                                ),
76                            ),
77                        ),
78                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
79                            Box::new(
80                                SyntheticsAssertionJSONSchemaTarget::new(
81                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
82                                    SyntheticsAssertionType::BODY,
83                                ).target(
84                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
85                                        .json_schema(
86                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
87                                        )
88                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
89                                ),
90                            ),
91                        )
92                    ],
93                )
94                .config_variables(
95                    vec![
96                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
97                            .example("content-type".to_string())
98                            .pattern("content-type".to_string())
99                    ],
100                )
101                .request(
102                    SyntheticsTestRequest::new()
103                        .certificate(
104                            SyntheticsTestRequestCertificate::new()
105                                .cert(
106                                    SyntheticsTestRequestCertificateItem::new()
107                                        .filename("cert-filename".to_string())
108                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
109                                )
110                                .key(
111                                    SyntheticsTestRequestCertificateItem::new()
112                                        .filename("key-filename".to_string())
113                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
114                                ),
115                        )
116                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
117                        .method("GET".to_string())
118                        .timeout(10.0 as f64)
119                        .url("https://datadoghq.com".to_string()),
120                ),
121            vec!["aws:us-east-2".to_string()],
122            "BDD test payload: synthetics_api_test_payload.json".to_string(),
123            "Example-Synthetic-updated".to_string(),
124            SyntheticsTestOptions::new()
125                .accept_self_signed(false)
126                .allow_insecure(true)
127                .follow_redirects(true)
128                .min_failure_duration(10)
129                .min_location_failed(1)
130                .monitor_name("Test-TestSyntheticsAPITestLifecycle-1623076664".to_string())
131                .monitor_priority(5)
132                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
133                .tick_every(60),
134            SyntheticsAPITestType::API,
135        )
136            .status(SyntheticsTestPauseStatus::LIVE)
137            .subtype(SyntheticsTestDetailsSubType::HTTP)
138            .tags(vec!["testing:api".to_string()]);
139    let configuration = datadog::Configuration::new();
140    let api = SyntheticsAPI::with_config(configuration);
141    let resp = api
142        .update_api_test(synthetics_api_test_public_id.clone(), body)
143        .await;
144    if let Ok(value) = resp {
145        println!("{:#?}", value);
146    } else {
147        println!("{:#?}", resp.unwrap_err());
148    }
149}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 153)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
examples/v1_synthetics_CreateSyntheticsAPITest_960766374.rs (line 159)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
85                            Box::new(
86                                SyntheticsAssertionJSONSchemaTarget::new(
87                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
91                                        .json_schema(
92                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
93                                        )
94                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
95                                ),
96                            ),
97                        ),
98                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
99                            Box::new(
100                                SyntheticsAssertionXPathTarget::new(
101                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
102                                    SyntheticsAssertionType::BODY,
103                                ).target(
104                                    SyntheticsAssertionXPathTargetTarget::new()
105                                        .operator("contains".to_string())
106                                        .target_value(
107                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
108                                                "0".to_string(),
109                                            ),
110                                        )
111                                        .x_path("target-xpath".to_string()),
112                                ),
113                            ),
114                        )
115                    ],
116                )
117                .config_variables(
118                    vec![
119                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
120                            .example("content-type".to_string())
121                            .pattern("content-type".to_string())
122                    ],
123                )
124                .request(
125                    SyntheticsTestRequest::new()
126                        .basic_auth(
127                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(
128                                Box::new(
129                                    SyntheticsBasicAuthOauthROP::new(
130                                        "https://datadog-token.com".to_string(),
131                                        "oauth-password".to_string(),
132                                        SyntheticsBasicAuthOauthTokenApiAuthentication::BODY,
133                                        SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
134                                        "oauth-usermame".to_string(),
135                                    )
136                                        .audience("audience".to_string())
137                                        .client_id("client-id".to_string())
138                                        .client_secret("client-secret".to_string())
139                                        .resource("resource".to_string())
140                                        .scope("yoyo".to_string()),
141                                ),
142                            ),
143                        )
144                        .certificate(
145                            SyntheticsTestRequestCertificate::new()
146                                .cert(
147                                    SyntheticsTestRequestCertificateItem::new()
148                                        .content("cert-content".to_string())
149                                        .filename("cert-filename".to_string())
150                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
151                                )
152                                .key(
153                                    SyntheticsTestRequestCertificateItem::new()
154                                        .content("key-content".to_string())
155                                        .filename("key-filename".to_string())
156                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
157                                ),
158                        )
159                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
160                        .method("GET".to_string())
161                        .proxy(
162                            SyntheticsTestRequestProxy::new(
163                                "https://datadoghq.com".to_string(),
164                            ).headers(BTreeMap::from([])),
165                        )
166                        .timeout(10.0 as f64)
167                        .url("https://datadoghq.com".to_string()),
168                ),
169            vec!["aws:us-east-2".to_string()],
170            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
171            "Example-Synthetic".to_string(),
172            SyntheticsTestOptions::new()
173                .accept_self_signed(false)
174                .allow_insecure(true)
175                .follow_redirects(true)
176                .min_failure_duration(10)
177                .min_location_failed(1)
178                .monitor_name("Example-Synthetic".to_string())
179                .monitor_priority(5)
180                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
181                .tick_every(60),
182            SyntheticsAPITestType::API,
183        )
184            .subtype(SyntheticsTestDetailsSubType::HTTP)
185            .tags(vec!["testing:api".to_string()]);
186    let configuration = datadog::Configuration::new();
187    let api = SyntheticsAPI::with_config(configuration);
188    let resp = api.create_synthetics_api_test(body).await;
189    if let Ok(value) = resp {
190        println!("{:#?}", value);
191    } else {
192        println!("{:#?}", resp.unwrap_err());
193    }
194}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 201)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 200)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 294)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn host(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1072503741.rs (line 32)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_3829801148.rs (line 46)
20async fn main() {
21    let body = SyntheticsAPITest::new(
22        SyntheticsAPITestConfig::new()
23            .assertions(vec![
24                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
25                    SyntheticsAssertionTarget::new(
26                        SyntheticsAssertionOperator::IS,
27                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
28                            "message".to_string(),
29                        ),
30                        SyntheticsAssertionType::RECEIVED_MESSAGE,
31                    ),
32                )),
33                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
34                    SyntheticsAssertionTarget::new(
35                        SyntheticsAssertionOperator::LESS_THAN,
36                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
37                            2000.0 as f64,
38                        ),
39                        SyntheticsAssertionType::RESPONSE_TIME,
40                    ),
41                )),
42            ])
43            .config_variables(vec![])
44            .request(
45                SyntheticsTestRequest::new()
46                    .host("https://datadoghq.com".to_string())
47                    .message("message".to_string())
48                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
49            ),
50        vec!["aws:us-east-2".to_string()],
51        "BDD test payload: synthetics_api_test_udp_payload.json".to_string(),
52        "Example-Synthetic".to_string(),
53        SyntheticsTestOptions::new()
54            .accept_self_signed(false)
55            .allow_insecure(true)
56            .follow_redirects(true)
57            .min_failure_duration(10)
58            .min_location_failed(1)
59            .monitor_name("Example-Synthetic".to_string())
60            .monitor_priority(5)
61            .retry(
62                SyntheticsTestOptionsRetry::new()
63                    .count(3)
64                    .interval(10.0 as f64),
65            )
66            .tick_every(60),
67        SyntheticsAPITestType::API,
68    )
69    .subtype(SyntheticsTestDetailsSubType::UDP)
70    .tags(vec!["testing:api".to_string()]);
71    let configuration = datadog::Configuration::new();
72    let api = SyntheticsAPI::with_config(configuration);
73    let resp = api.create_synthetics_api_test(body).await;
74    if let Ok(value) = resp {
75        println!("{:#?}", value);
76    } else {
77        println!("{:#?}", resp.unwrap_err());
78    }
79}
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 56)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 127)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn http_version(self, value: SyntheticsTestOptionsHTTPVersion) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (line 56)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 70)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn is_message_base64_encoded(self, value: bool) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 295)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn message(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_2472747642.rs (line 45)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_3829801148.rs (line 47)
20async fn main() {
21    let body = SyntheticsAPITest::new(
22        SyntheticsAPITestConfig::new()
23            .assertions(vec![
24                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
25                    SyntheticsAssertionTarget::new(
26                        SyntheticsAssertionOperator::IS,
27                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
28                            "message".to_string(),
29                        ),
30                        SyntheticsAssertionType::RECEIVED_MESSAGE,
31                    ),
32                )),
33                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
34                    SyntheticsAssertionTarget::new(
35                        SyntheticsAssertionOperator::LESS_THAN,
36                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
37                            2000.0 as f64,
38                        ),
39                        SyntheticsAssertionType::RESPONSE_TIME,
40                    ),
41                )),
42            ])
43            .config_variables(vec![])
44            .request(
45                SyntheticsTestRequest::new()
46                    .host("https://datadoghq.com".to_string())
47                    .message("message".to_string())
48                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
49            ),
50        vec!["aws:us-east-2".to_string()],
51        "BDD test payload: synthetics_api_test_udp_payload.json".to_string(),
52        "Example-Synthetic".to_string(),
53        SyntheticsTestOptions::new()
54            .accept_self_signed(false)
55            .allow_insecure(true)
56            .follow_redirects(true)
57            .min_failure_duration(10)
58            .min_location_failed(1)
59            .monitor_name("Example-Synthetic".to_string())
60            .monitor_priority(5)
61            .retry(
62                SyntheticsTestOptionsRetry::new()
63                    .count(3)
64                    .interval(10.0 as f64),
65            )
66            .tick_every(60),
67        SyntheticsAPITestType::API,
68    )
69    .subtype(SyntheticsTestDetailsSubType::UDP)
70    .tags(vec!["testing:api".to_string()]);
71    let configuration = datadog::Configuration::new();
72    let api = SyntheticsAPI::with_config(configuration);
73    let resp = api.create_synthetics_api_test(body).await;
74    if let Ok(value) = resp {
75        println!("{:#?}", value);
76    } else {
77        println!("{:#?}", resp.unwrap_err());
78    }
79}
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 57)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 128)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn metadata(self, value: BTreeMap<String, String>) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 58)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 129)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn method(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsBrowserTest.rs (line 24)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsBrowserTest_2932742688.rs (line 26)
20async fn main() {
21    let body = SyntheticsBrowserTest::new(
22        SyntheticsBrowserTestConfig::new(
23            vec![],
24            SyntheticsTestRequest::new()
25                .certificate_domains(vec!["https://datadoghq.com".to_string()])
26                .method("GET".to_string())
27                .url("https://datadoghq.com".to_string()),
28        )
29        .config_variables(vec![SyntheticsConfigVariable::new(
30            "PROPERTY".to_string(),
31            SyntheticsConfigVariableType::TEXT,
32        )
33        .example("content-type".to_string())
34        .pattern("content-type".to_string())])
35        .set_cookie("name:test".to_string()),
36        vec!["aws:us-east-2".to_string()],
37        "Test message".to_string(),
38        "Example-Synthetic".to_string(),
39        SyntheticsTestOptions::new()
40            .accept_self_signed(false)
41            .allow_insecure(true)
42            .ci(SyntheticsTestCiOptions::new(
43                SyntheticsTestExecutionRule::SKIPPED,
44            ))
45            .device_ids(vec!["tablet".to_string()])
46            .disable_cors(true)
47            .disable_csp(true)
48            .follow_redirects(true)
49            .ignore_server_certificate_error(true)
50            .initial_navigation_timeout(200)
51            .min_failure_duration(10)
52            .min_location_failed(1)
53            .no_screenshot(true)
54            .retry(
55                SyntheticsTestOptionsRetry::new()
56                    .count(2)
57                    .interval(10.0 as f64),
58            )
59            .rum_settings(
60                SyntheticsBrowserTestRumSettings::new(true)
61                    .application_id("mockApplicationId".to_string())
62                    .client_token_id(12345),
63            )
64            .tick_every(300),
65        SyntheticsBrowserTestType::BROWSER,
66    )
67    .steps(vec![SyntheticsStep::new()
68        .allow_failure(false)
69        .is_critical(true)
70        .name("Refresh page".to_string())
71        .params(BTreeMap::new())
72        .type_(SyntheticsStepType::REFRESH)])
73    .tags(vec!["testing:browser".to_string()]);
74    let configuration = datadog::Configuration::new();
75    let api = SyntheticsAPI::with_config(configuration);
76    let resp = api.create_synthetics_browser_test(body).await;
77    if let Ok(value) = resp {
78        println!("{:#?}", value);
79    } else {
80        println!("{:#?}", resp.unwrap_err());
81    }
82}
examples/v1_synthetics_CreateSyntheticsBrowserTest_397420811.rs (line 25)
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}
examples/v1_synthetics_CreateSyntheticsAPITest.rs (line 41)
27async fn main() {
28    let body = SyntheticsAPITest::new(
29        SyntheticsAPITestConfig::new()
30            .assertions(vec![SyntheticsAssertion::SyntheticsAssertionTarget(
31                Box::new(SyntheticsAssertionTarget::new(
32                    SyntheticsAssertionOperator::LESS_THAN,
33                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
34                        1000.0 as f64,
35                    ),
36                    SyntheticsAssertionType::RESPONSE_TIME,
37                )),
38            )])
39            .request(
40                SyntheticsTestRequest::new()
41                    .method("GET".to_string())
42                    .url("https://example.com".to_string()),
43            ),
44        vec!["aws:eu-west-3".to_string()],
45        "Notification message".to_string(),
46        "Example test name".to_string(),
47        SyntheticsTestOptions::new()
48            .ci(SyntheticsTestCiOptions::new(
49                SyntheticsTestExecutionRule::BLOCKING,
50            ))
51            .device_ids(vec!["chrome.laptop_large".to_string()])
52            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
53            .monitor_options(
54                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
55                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
56                ),
57            )
58            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
59            .retry(SyntheticsTestOptionsRetry::new())
60            .rum_settings(
61                SyntheticsBrowserTestRumSettings::new(true)
62                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
63                    .client_token_id(12345),
64            )
65            .scheduling(SyntheticsTestOptionsScheduling::new(
66                vec![
67                    SyntheticsTestOptionsSchedulingTimeframe::new(
68                        1,
69                        "07:00".to_string(),
70                        "16:00".to_string(),
71                    ),
72                    SyntheticsTestOptionsSchedulingTimeframe::new(
73                        3,
74                        "07:00".to_string(),
75                        "16:00".to_string(),
76                    ),
77                ],
78                "America/New_York".to_string(),
79            )),
80        SyntheticsAPITestType::API,
81    )
82    .status(SyntheticsTestPauseStatus::LIVE)
83    .subtype(SyntheticsTestDetailsSubType::HTTP)
84    .tags(vec!["env:production".to_string()]);
85    let configuration = datadog::Configuration::new();
86    let api = SyntheticsAPI::with_config(configuration);
87    let resp = api.create_synthetics_api_test(body).await;
88    if let Ok(value) = resp {
89        println!("{:#?}", value);
90    } else {
91        println!("{:#?}", resp.unwrap_err());
92    }
93}
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 59)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
examples/v1_synthetics_UpdateAPITest.rs (line 117)
31async fn main() {
32    // there is a valid "synthetics_api_test" in the system
33    let synthetics_api_test_public_id = std::env::var("SYNTHETICS_API_TEST_PUBLIC_ID").unwrap();
34    let body =
35        SyntheticsAPITest::new(
36            SyntheticsAPITestConfig::new()
37                .assertions(
38                    vec![
39                        SyntheticsAssertion::SyntheticsAssertionTarget(
40                            Box::new(
41                                SyntheticsAssertionTarget::new(
42                                    SyntheticsAssertionOperator::IS,
43                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
44                                        "text/html".to_string(),
45                                    ),
46                                    SyntheticsAssertionType::HEADER,
47                                ).property("{{ PROPERTY }}".to_string()),
48                            ),
49                        ),
50                        SyntheticsAssertion::SyntheticsAssertionTarget(
51                            Box::new(
52                                SyntheticsAssertionTarget::new(
53                                    SyntheticsAssertionOperator::LESS_THAN,
54                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
55                                        2000.0 as f64,
56                                    ),
57                                    SyntheticsAssertionType::RESPONSE_TIME,
58                                ),
59                            ),
60                        ),
61                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
62                            Box::new(
63                                SyntheticsAssertionJSONPathTarget::new(
64                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
65                                    SyntheticsAssertionType::BODY,
66                                ).target(
67                                    SyntheticsAssertionJSONPathTargetTarget::new()
68                                        .json_path("topKey".to_string())
69                                        .operator("isNot".to_string())
70                                        .target_value(
71                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
72                                                "0".to_string(),
73                                            ),
74                                        ),
75                                ),
76                            ),
77                        ),
78                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
79                            Box::new(
80                                SyntheticsAssertionJSONSchemaTarget::new(
81                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
82                                    SyntheticsAssertionType::BODY,
83                                ).target(
84                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
85                                        .json_schema(
86                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
87                                        )
88                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
89                                ),
90                            ),
91                        )
92                    ],
93                )
94                .config_variables(
95                    vec![
96                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
97                            .example("content-type".to_string())
98                            .pattern("content-type".to_string())
99                    ],
100                )
101                .request(
102                    SyntheticsTestRequest::new()
103                        .certificate(
104                            SyntheticsTestRequestCertificate::new()
105                                .cert(
106                                    SyntheticsTestRequestCertificateItem::new()
107                                        .filename("cert-filename".to_string())
108                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
109                                )
110                                .key(
111                                    SyntheticsTestRequestCertificateItem::new()
112                                        .filename("key-filename".to_string())
113                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
114                                ),
115                        )
116                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
117                        .method("GET".to_string())
118                        .timeout(10.0 as f64)
119                        .url("https://datadoghq.com".to_string()),
120                ),
121            vec!["aws:us-east-2".to_string()],
122            "BDD test payload: synthetics_api_test_payload.json".to_string(),
123            "Example-Synthetic-updated".to_string(),
124            SyntheticsTestOptions::new()
125                .accept_self_signed(false)
126                .allow_insecure(true)
127                .follow_redirects(true)
128                .min_failure_duration(10)
129                .min_location_failed(1)
130                .monitor_name("Test-TestSyntheticsAPITestLifecycle-1623076664".to_string())
131                .monitor_priority(5)
132                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
133                .tick_every(60),
134            SyntheticsAPITestType::API,
135        )
136            .status(SyntheticsTestPauseStatus::LIVE)
137            .subtype(SyntheticsTestDetailsSubType::HTTP)
138            .tags(vec!["testing:api".to_string()]);
139    let configuration = datadog::Configuration::new();
140    let api = SyntheticsAPI::with_config(configuration);
141    let resp = api
142        .update_api_test(synthetics_api_test_public_id.clone(), body)
143        .await;
144    if let Ok(value) = resp {
145        println!("{:#?}", value);
146    } else {
147        println!("{:#?}", resp.unwrap_err());
148    }
149}
Source

pub fn no_saving_response_body(self, value: bool) -> Self

Source

pub fn number_of_packets(self, value: i32) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 255)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn persist_cookies(self, value: bool) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 155)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 203)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 202)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
Source

pub fn port(self, value: SyntheticsTestRequestPort) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1072503741.rs (lines 33-37)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_3829801148.rs (line 48)
20async fn main() {
21    let body = SyntheticsAPITest::new(
22        SyntheticsAPITestConfig::new()
23            .assertions(vec![
24                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
25                    SyntheticsAssertionTarget::new(
26                        SyntheticsAssertionOperator::IS,
27                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
28                            "message".to_string(),
29                        ),
30                        SyntheticsAssertionType::RECEIVED_MESSAGE,
31                    ),
32                )),
33                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
34                    SyntheticsAssertionTarget::new(
35                        SyntheticsAssertionOperator::LESS_THAN,
36                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
37                            2000.0 as f64,
38                        ),
39                        SyntheticsAssertionType::RESPONSE_TIME,
40                    ),
41                )),
42            ])
43            .config_variables(vec![])
44            .request(
45                SyntheticsTestRequest::new()
46                    .host("https://datadoghq.com".to_string())
47                    .message("message".to_string())
48                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
49            ),
50        vec!["aws:us-east-2".to_string()],
51        "BDD test payload: synthetics_api_test_udp_payload.json".to_string(),
52        "Example-Synthetic".to_string(),
53        SyntheticsTestOptions::new()
54            .accept_self_signed(false)
55            .allow_insecure(true)
56            .follow_redirects(true)
57            .min_failure_duration(10)
58            .min_location_failed(1)
59            .monitor_name("Example-Synthetic".to_string())
60            .monitor_priority(5)
61            .retry(
62                SyntheticsTestOptionsRetry::new()
63                    .count(3)
64                    .interval(10.0 as f64),
65            )
66            .tick_every(60),
67        SyntheticsAPITestType::API,
68    )
69    .subtype(SyntheticsTestDetailsSubType::UDP)
70    .tags(vec!["testing:api".to_string()]);
71    let configuration = datadog::Configuration::new();
72    let api = SyntheticsAPI::with_config(configuration);
73    let resp = api.create_synthetics_api_test(body).await;
74    if let Ok(value) = resp {
75        println!("{:#?}", value);
76    } else {
77        println!("{:#?}", resp.unwrap_err());
78    }
79}
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 60)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 131)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn proxy(self, value: SyntheticsTestRequestProxy) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateBrowserTest.rs (lines 57-59)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (lines 156-160)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
examples/v1_synthetics_CreateSyntheticsAPITest_960766374.rs (lines 161-165)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
85                            Box::new(
86                                SyntheticsAssertionJSONSchemaTarget::new(
87                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
91                                        .json_schema(
92                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
93                                        )
94                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
95                                ),
96                            ),
97                        ),
98                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
99                            Box::new(
100                                SyntheticsAssertionXPathTarget::new(
101                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
102                                    SyntheticsAssertionType::BODY,
103                                ).target(
104                                    SyntheticsAssertionXPathTargetTarget::new()
105                                        .operator("contains".to_string())
106                                        .target_value(
107                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
108                                                "0".to_string(),
109                                            ),
110                                        )
111                                        .x_path("target-xpath".to_string()),
112                                ),
113                            ),
114                        )
115                    ],
116                )
117                .config_variables(
118                    vec![
119                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
120                            .example("content-type".to_string())
121                            .pattern("content-type".to_string())
122                    ],
123                )
124                .request(
125                    SyntheticsTestRequest::new()
126                        .basic_auth(
127                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(
128                                Box::new(
129                                    SyntheticsBasicAuthOauthROP::new(
130                                        "https://datadog-token.com".to_string(),
131                                        "oauth-password".to_string(),
132                                        SyntheticsBasicAuthOauthTokenApiAuthentication::BODY,
133                                        SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
134                                        "oauth-usermame".to_string(),
135                                    )
136                                        .audience("audience".to_string())
137                                        .client_id("client-id".to_string())
138                                        .client_secret("client-secret".to_string())
139                                        .resource("resource".to_string())
140                                        .scope("yoyo".to_string()),
141                                ),
142                            ),
143                        )
144                        .certificate(
145                            SyntheticsTestRequestCertificate::new()
146                                .cert(
147                                    SyntheticsTestRequestCertificateItem::new()
148                                        .content("cert-content".to_string())
149                                        .filename("cert-filename".to_string())
150                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
151                                )
152                                .key(
153                                    SyntheticsTestRequestCertificateItem::new()
154                                        .content("key-content".to_string())
155                                        .filename("key-filename".to_string())
156                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
157                                ),
158                        )
159                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
160                        .method("GET".to_string())
161                        .proxy(
162                            SyntheticsTestRequestProxy::new(
163                                "https://datadoghq.com".to_string(),
164                            ).headers(BTreeMap::from([])),
165                        )
166                        .timeout(10.0 as f64)
167                        .url("https://datadoghq.com".to_string()),
168                ),
169            vec!["aws:us-east-2".to_string()],
170            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
171            "Example-Synthetic".to_string(),
172            SyntheticsTestOptions::new()
173                .accept_self_signed(false)
174                .allow_insecure(true)
175                .follow_redirects(true)
176                .min_failure_duration(10)
177                .min_location_failed(1)
178                .monitor_name("Example-Synthetic".to_string())
179                .monitor_priority(5)
180                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
181                .tick_every(60),
182            SyntheticsAPITestType::API,
183        )
184            .subtype(SyntheticsTestDetailsSubType::HTTP)
185            .tags(vec!["testing:api".to_string()]);
186    let configuration = datadog::Configuration::new();
187    let api = SyntheticsAPI::with_config(configuration);
188    let resp = api.create_synthetics_api_test(body).await;
189    if let Ok(value) = resp {
190        println!("{:#?}", value);
191    } else {
192        println!("{:#?}", resp.unwrap_err());
193    }
194}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (lines 204-208)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (lines 203-207)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
Source

pub fn query(self, value: BTreeMap<String, Value>) -> Self

Source

pub fn servername(self, value: String) -> Self

Source

pub fn service(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1402674167.rs (line 61)
21async fn main() {
22    let body = SyntheticsAPITest::new(
23        SyntheticsAPITestConfig::new()
24            .assertions(vec![
25                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
26                    SyntheticsAssertionTarget::new(
27                        SyntheticsAssertionOperator::IS,
28                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
29                            1.0 as f64,
30                        ),
31                        SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
32                    ),
33                )),
34                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
35                    SyntheticsAssertionTarget::new(
36                        SyntheticsAssertionOperator::IS,
37                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
38                            "proto target".to_string(),
39                        ),
40                        SyntheticsAssertionType::GRPC_PROTO,
41                    ),
42                )),
43                SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
44                    SyntheticsAssertionTarget::new(
45                        SyntheticsAssertionOperator::IS,
46                        SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
47                            "123".to_string(),
48                        ),
49                        SyntheticsAssertionType::GRPC_METADATA,
50                    )
51                    .property("property".to_string()),
52                )),
53            ])
54            .request(
55                SyntheticsTestRequest::new()
56                    .host("localhost".to_string())
57                    .message("".to_string())
58                    .metadata(BTreeMap::from([]))
59                    .method("GET".to_string())
60                    .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(50051))
61                    .service("Hello".to_string()),
62            ),
63        vec!["aws:us-east-2".to_string()],
64        "BDD test payload: synthetics_api_grpc_test_payload.json".to_string(),
65        "Example-Synthetic".to_string(),
66        SyntheticsTestOptions::new()
67            .min_failure_duration(0)
68            .min_location_failed(1)
69            .monitor_name("Example-Synthetic".to_string())
70            .monitor_options(SyntheticsTestOptionsMonitorOptions::new().renotify_interval(0))
71            .tick_every(60),
72        SyntheticsAPITestType::API,
73    )
74    .subtype(SyntheticsTestDetailsSubType::GRPC)
75    .tags(vec!["testing:api".to_string()]);
76    let configuration = datadog::Configuration::new();
77    let api = SyntheticsAPI::with_config(configuration);
78    let resp = api.create_synthetics_api_test(body).await;
79    if let Ok(value) = resp {
80        println!("{:#?}", value);
81    } else {
82        println!("{:#?}", resp.unwrap_err());
83    }
84}
More examples
Hide additional examples
examples/v1_synthetics_UpdateBrowserTest.rs (line 60)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 132)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn should_track_hops(self, value: bool) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 226)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn timeout(self, value: f64) -> Self

Examples found in repository?
examples/v1_synthetics_UpdateAPITest.rs (line 118)
31async fn main() {
32    // there is a valid "synthetics_api_test" in the system
33    let synthetics_api_test_public_id = std::env::var("SYNTHETICS_API_TEST_PUBLIC_ID").unwrap();
34    let body =
35        SyntheticsAPITest::new(
36            SyntheticsAPITestConfig::new()
37                .assertions(
38                    vec![
39                        SyntheticsAssertion::SyntheticsAssertionTarget(
40                            Box::new(
41                                SyntheticsAssertionTarget::new(
42                                    SyntheticsAssertionOperator::IS,
43                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
44                                        "text/html".to_string(),
45                                    ),
46                                    SyntheticsAssertionType::HEADER,
47                                ).property("{{ PROPERTY }}".to_string()),
48                            ),
49                        ),
50                        SyntheticsAssertion::SyntheticsAssertionTarget(
51                            Box::new(
52                                SyntheticsAssertionTarget::new(
53                                    SyntheticsAssertionOperator::LESS_THAN,
54                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
55                                        2000.0 as f64,
56                                    ),
57                                    SyntheticsAssertionType::RESPONSE_TIME,
58                                ),
59                            ),
60                        ),
61                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
62                            Box::new(
63                                SyntheticsAssertionJSONPathTarget::new(
64                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
65                                    SyntheticsAssertionType::BODY,
66                                ).target(
67                                    SyntheticsAssertionJSONPathTargetTarget::new()
68                                        .json_path("topKey".to_string())
69                                        .operator("isNot".to_string())
70                                        .target_value(
71                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
72                                                "0".to_string(),
73                                            ),
74                                        ),
75                                ),
76                            ),
77                        ),
78                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
79                            Box::new(
80                                SyntheticsAssertionJSONSchemaTarget::new(
81                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
82                                    SyntheticsAssertionType::BODY,
83                                ).target(
84                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
85                                        .json_schema(
86                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
87                                        )
88                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
89                                ),
90                            ),
91                        )
92                    ],
93                )
94                .config_variables(
95                    vec![
96                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
97                            .example("content-type".to_string())
98                            .pattern("content-type".to_string())
99                    ],
100                )
101                .request(
102                    SyntheticsTestRequest::new()
103                        .certificate(
104                            SyntheticsTestRequestCertificate::new()
105                                .cert(
106                                    SyntheticsTestRequestCertificateItem::new()
107                                        .filename("cert-filename".to_string())
108                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
109                                )
110                                .key(
111                                    SyntheticsTestRequestCertificateItem::new()
112                                        .filename("key-filename".to_string())
113                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
114                                ),
115                        )
116                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
117                        .method("GET".to_string())
118                        .timeout(10.0 as f64)
119                        .url("https://datadoghq.com".to_string()),
120                ),
121            vec!["aws:us-east-2".to_string()],
122            "BDD test payload: synthetics_api_test_payload.json".to_string(),
123            "Example-Synthetic-updated".to_string(),
124            SyntheticsTestOptions::new()
125                .accept_self_signed(false)
126                .allow_insecure(true)
127                .follow_redirects(true)
128                .min_failure_duration(10)
129                .min_location_failed(1)
130                .monitor_name("Test-TestSyntheticsAPITestLifecycle-1623076664".to_string())
131                .monitor_priority(5)
132                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
133                .tick_every(60),
134            SyntheticsAPITestType::API,
135        )
136            .status(SyntheticsTestPauseStatus::LIVE)
137            .subtype(SyntheticsTestDetailsSubType::HTTP)
138            .tags(vec!["testing:api".to_string()]);
139    let configuration = datadog::Configuration::new();
140    let api = SyntheticsAPI::with_config(configuration);
141    let resp = api
142        .update_api_test(synthetics_api_test_public_id.clone(), body)
143        .await;
144    if let Ok(value) = resp {
145        println!("{:#?}", value);
146    } else {
147        println!("{:#?}", resp.unwrap_err());
148    }
149}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 161)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85                            Box::new(
86                                SyntheticsAssertionXPathTarget::new(
87                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionXPathTargetTarget::new()
91                                        .operator("contains".to_string())
92                                        .target_value(
93                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94                                                "0".to_string(),
95                                            ),
96                                        )
97                                        .x_path("target-xpath".to_string()),
98                                ),
99                            ),
100                        )
101                    ],
102                )
103                .config_variables(
104                    vec![
105                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106                            .example("content-type".to_string())
107                            .pattern("content-type".to_string())
108                    ],
109                )
110                .request(
111                    SyntheticsTestRequest::new()
112                        .basic_auth(
113                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114                                Box::new(
115                                    SyntheticsBasicAuthOauthClient::new(
116                                        "https://datadog-token.com".to_string(),
117                                        "client-id".to_string(),
118                                        "client-secret".to_string(),
119                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121                                    )
122                                        .audience("audience".to_string())
123                                        .resource("resource".to_string())
124                                        .scope("yoyo".to_string()),
125                                ),
126                            ),
127                        )
128                        .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129                        .certificate(
130                            SyntheticsTestRequestCertificate::new()
131                                .cert(
132                                    SyntheticsTestRequestCertificateItem::new()
133                                        .content("cert-content".to_string())
134                                        .filename("cert-filename".to_string())
135                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136                                )
137                                .key(
138                                    SyntheticsTestRequestCertificateItem::new()
139                                        .content("key-content".to_string())
140                                        .filename("key-filename".to_string())
141                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142                                ),
143                        )
144                        .files(
145                            vec![
146                                SyntheticsTestRequestBodyFile::new()
147                                    .content("file content".to_string())
148                                    .name("file name".to_string())
149                                    .original_file_name("image.png".to_string())
150                                    .type_("file type".to_string())
151                            ],
152                        )
153                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154                        .method("GET".to_string())
155                        .persist_cookies(true)
156                        .proxy(
157                            SyntheticsTestRequestProxy::new(
158                                "https://datadoghq.com".to_string(),
159                            ).headers(BTreeMap::from([])),
160                        )
161                        .timeout(10.0 as f64)
162                        .url("https://datadoghq.com".to_string()),
163                ),
164            vec!["aws:us-east-2".to_string()],
165            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166            "Example-Synthetic".to_string(),
167            SyntheticsTestOptions::new()
168                .accept_self_signed(false)
169                .allow_insecure(true)
170                .follow_redirects(true)
171                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172                .min_failure_duration(10)
173                .min_location_failed(1)
174                .monitor_name("Example-Synthetic".to_string())
175                .monitor_priority(5)
176                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177                .tick_every(60),
178            SyntheticsAPITestType::API,
179        )
180            .subtype(SyntheticsTestDetailsSubType::HTTP)
181            .tags(vec!["testing:api".to_string()]);
182    let configuration = datadog::Configuration::new();
183    let api = SyntheticsAPI::with_config(configuration);
184    let resp = api.create_synthetics_api_test(body).await;
185    if let Ok(value) = resp {
186        println!("{:#?}", value);
187    } else {
188        println!("{:#?}", resp.unwrap_err());
189    }
190}
examples/v1_synthetics_CreateSyntheticsAPITest_960766374.rs (line 166)
39async fn main() {
40    let body =
41        SyntheticsAPITest::new(
42            SyntheticsAPITestConfig::new()
43                .assertions(
44                    vec![
45                        SyntheticsAssertion::SyntheticsAssertionTarget(
46                            Box::new(
47                                SyntheticsAssertionTarget::new(
48                                    SyntheticsAssertionOperator::IS,
49                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50                                        "text/html".to_string(),
51                                    ),
52                                    SyntheticsAssertionType::HEADER,
53                                ).property("{{ PROPERTY }}".to_string()),
54                            ),
55                        ),
56                        SyntheticsAssertion::SyntheticsAssertionTarget(
57                            Box::new(
58                                SyntheticsAssertionTarget::new(
59                                    SyntheticsAssertionOperator::LESS_THAN,
60                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61                                        2000.0 as f64,
62                                    ),
63                                    SyntheticsAssertionType::RESPONSE_TIME,
64                                ),
65                            ),
66                        ),
67                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68                            Box::new(
69                                SyntheticsAssertionJSONPathTarget::new(
70                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71                                    SyntheticsAssertionType::BODY,
72                                ).target(
73                                    SyntheticsAssertionJSONPathTargetTarget::new()
74                                        .json_path("topKey".to_string())
75                                        .operator("isNot".to_string())
76                                        .target_value(
77                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78                                                "0".to_string(),
79                                            ),
80                                        ),
81                                ),
82                            ),
83                        ),
84                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
85                            Box::new(
86                                SyntheticsAssertionJSONSchemaTarget::new(
87                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
88                                    SyntheticsAssertionType::BODY,
89                                ).target(
90                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
91                                        .json_schema(
92                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
93                                        )
94                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
95                                ),
96                            ),
97                        ),
98                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
99                            Box::new(
100                                SyntheticsAssertionXPathTarget::new(
101                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
102                                    SyntheticsAssertionType::BODY,
103                                ).target(
104                                    SyntheticsAssertionXPathTargetTarget::new()
105                                        .operator("contains".to_string())
106                                        .target_value(
107                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
108                                                "0".to_string(),
109                                            ),
110                                        )
111                                        .x_path("target-xpath".to_string()),
112                                ),
113                            ),
114                        )
115                    ],
116                )
117                .config_variables(
118                    vec![
119                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
120                            .example("content-type".to_string())
121                            .pattern("content-type".to_string())
122                    ],
123                )
124                .request(
125                    SyntheticsTestRequest::new()
126                        .basic_auth(
127                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(
128                                Box::new(
129                                    SyntheticsBasicAuthOauthROP::new(
130                                        "https://datadog-token.com".to_string(),
131                                        "oauth-password".to_string(),
132                                        SyntheticsBasicAuthOauthTokenApiAuthentication::BODY,
133                                        SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
134                                        "oauth-usermame".to_string(),
135                                    )
136                                        .audience("audience".to_string())
137                                        .client_id("client-id".to_string())
138                                        .client_secret("client-secret".to_string())
139                                        .resource("resource".to_string())
140                                        .scope("yoyo".to_string()),
141                                ),
142                            ),
143                        )
144                        .certificate(
145                            SyntheticsTestRequestCertificate::new()
146                                .cert(
147                                    SyntheticsTestRequestCertificateItem::new()
148                                        .content("cert-content".to_string())
149                                        .filename("cert-filename".to_string())
150                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
151                                )
152                                .key(
153                                    SyntheticsTestRequestCertificateItem::new()
154                                        .content("key-content".to_string())
155                                        .filename("key-filename".to_string())
156                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
157                                ),
158                        )
159                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
160                        .method("GET".to_string())
161                        .proxy(
162                            SyntheticsTestRequestProxy::new(
163                                "https://datadoghq.com".to_string(),
164                            ).headers(BTreeMap::from([])),
165                        )
166                        .timeout(10.0 as f64)
167                        .url("https://datadoghq.com".to_string()),
168                ),
169            vec!["aws:us-east-2".to_string()],
170            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
171            "Example-Synthetic".to_string(),
172            SyntheticsTestOptions::new()
173                .accept_self_signed(false)
174                .allow_insecure(true)
175                .follow_redirects(true)
176                .min_failure_duration(10)
177                .min_location_failed(1)
178                .monitor_name("Example-Synthetic".to_string())
179                .monitor_priority(5)
180                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
181                .tick_every(60),
182            SyntheticsAPITestType::API,
183        )
184            .subtype(SyntheticsTestDetailsSubType::HTTP)
185            .tags(vec!["testing:api".to_string()]);
186    let configuration = datadog::Configuration::new();
187    let api = SyntheticsAPI::with_config(configuration);
188    let resp = api.create_synthetics_api_test(body).await;
189    if let Ok(value) = resp {
190        println!("{:#?}", value);
191    } else {
192        println!("{:#?}", resp.unwrap_err());
193    }
194}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 209)
46async fn main() {
47    let body =
48        SyntheticsAPITest::new(
49            SyntheticsAPITestConfig::new()
50                .assertions(
51                    vec![
52                        SyntheticsAssertion::SyntheticsAssertionTarget(
53                            Box::new(
54                                SyntheticsAssertionTarget::new(
55                                    SyntheticsAssertionOperator::IS,
56                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57                                        "text/html".to_string(),
58                                    ),
59                                    SyntheticsAssertionType::HEADER,
60                                ).property("{{ PROPERTY }}".to_string()),
61                            ),
62                        ),
63                        SyntheticsAssertion::SyntheticsAssertionTarget(
64                            Box::new(
65                                SyntheticsAssertionTarget::new(
66                                    SyntheticsAssertionOperator::LESS_THAN,
67                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68                                        2000.0 as f64,
69                                    ),
70                                    SyntheticsAssertionType::RESPONSE_TIME,
71                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72                            ),
73                        ),
74                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75                            Box::new(
76                                SyntheticsAssertionJSONPathTarget::new(
77                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78                                    SyntheticsAssertionType::BODY,
79                                ).target(
80                                    SyntheticsAssertionJSONPathTargetTarget::new()
81                                        .json_path("topKey".to_string())
82                                        .operator("isNot".to_string())
83                                        .target_value(
84                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85                                                "0".to_string(),
86                                            ),
87                                        ),
88                                ),
89                            ),
90                        ),
91                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92                            Box::new(
93                                SyntheticsAssertionJSONPathTarget::new(
94                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95                                    SyntheticsAssertionType::BODY,
96                                ).target(
97                                    SyntheticsAssertionJSONPathTargetTarget::new()
98                                        .elements_operator("atLeastOneElementMatches".to_string())
99                                        .json_path("topKey".to_string())
100                                        .operator("isNot".to_string())
101                                        .target_value(
102                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103                                                "0".to_string(),
104                                            ),
105                                        ),
106                                ),
107                            ),
108                        ),
109                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110                            Box::new(
111                                SyntheticsAssertionJSONSchemaTarget::new(
112                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113                                    SyntheticsAssertionType::BODY,
114                                ).target(
115                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
116                                        .json_schema(
117                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118                                        )
119                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120                                ),
121                            ),
122                        ),
123                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124                            Box::new(
125                                SyntheticsAssertionXPathTarget::new(
126                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127                                    SyntheticsAssertionType::BODY,
128                                ).target(
129                                    SyntheticsAssertionXPathTargetTarget::new()
130                                        .operator("contains".to_string())
131                                        .target_value(
132                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133                                                "0".to_string(),
134                                            ),
135                                        )
136                                        .x_path("target-xpath".to_string()),
137                                ),
138                            ),
139                        ),
140                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141                            Box::new(
142                                SyntheticsAssertionBodyHashTarget::new(
143                                    SyntheticsAssertionBodyHashOperator::MD5,
144                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145                                        "a".to_string(),
146                                    ),
147                                    SyntheticsAssertionBodyHashType::BODY_HASH,
148                                ),
149                            ),
150                        ),
151                        SyntheticsAssertion::SyntheticsAssertionJavascript(
152                            Box::new(
153                                SyntheticsAssertionJavascript::new(
154                                    "const hello = 'world';".to_string(),
155                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
156                                ),
157                            ),
158                        )
159                    ],
160                )
161                .config_variables(
162                    vec![
163                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164                            .example("content-type".to_string())
165                            .pattern("content-type".to_string())
166                    ],
167                )
168                .request(
169                    SyntheticsTestRequest::new()
170                        .basic_auth(
171                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172                                Box::new(
173                                    SyntheticsBasicAuthOauthClient::new(
174                                        "https://datadog-token.com".to_string(),
175                                        "client-id".to_string(),
176                                        "client-secret".to_string(),
177                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179                                    )
180                                        .audience("audience".to_string())
181                                        .resource("resource".to_string())
182                                        .scope("yoyo".to_string()),
183                                ),
184                            ),
185                        )
186                        .certificate(
187                            SyntheticsTestRequestCertificate::new()
188                                .cert(
189                                    SyntheticsTestRequestCertificateItem::new()
190                                        .content("cert-content".to_string())
191                                        .filename("cert-filename".to_string())
192                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193                                )
194                                .key(
195                                    SyntheticsTestRequestCertificateItem::new()
196                                        .content("key-content".to_string())
197                                        .filename("key-filename".to_string())
198                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199                                ),
200                        )
201                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202                        .method("GET".to_string())
203                        .persist_cookies(true)
204                        .proxy(
205                            SyntheticsTestRequestProxy::new(
206                                "https://datadoghq.com".to_string(),
207                            ).headers(BTreeMap::from([])),
208                        )
209                        .timeout(10.0 as f64)
210                        .url("https://datadoghq.com".to_string()),
211                )
212                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213            vec!["aws:us-east-2".to_string()],
214            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215            "Example-Synthetic".to_string(),
216            SyntheticsTestOptions::new()
217                .accept_self_signed(false)
218                .allow_insecure(true)
219                .follow_redirects(true)
220                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221                .min_failure_duration(10)
222                .min_location_failed(1)
223                .monitor_name("Example-Synthetic".to_string())
224                .monitor_priority(5)
225                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226                .tick_every(60),
227            SyntheticsAPITestType::API,
228        )
229            .subtype(SyntheticsTestDetailsSubType::HTTP)
230            .tags(vec!["testing:api".to_string()]);
231    let configuration = datadog::Configuration::new();
232    let api = SyntheticsAPI::with_config(configuration);
233    let resp = api.create_synthetics_api_test(body).await;
234    if let Ok(value) = resp {
235        println!("{:#?}", value);
236    } else {
237        println!("{:#?}", resp.unwrap_err());
238    }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 208)
45async fn main() {
46    let body =
47        SyntheticsAPITest::new(
48            SyntheticsAPITestConfig::new()
49                .assertions(
50                    vec![
51                        SyntheticsAssertion::SyntheticsAssertionTarget(
52                            Box::new(
53                                SyntheticsAssertionTarget::new(
54                                    SyntheticsAssertionOperator::IS,
55                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56                                        "text/html".to_string(),
57                                    ),
58                                    SyntheticsAssertionType::HEADER,
59                                ).property("{{ PROPERTY }}".to_string()),
60                            ),
61                        ),
62                        SyntheticsAssertion::SyntheticsAssertionTarget(
63                            Box::new(
64                                SyntheticsAssertionTarget::new(
65                                    SyntheticsAssertionOperator::LESS_THAN,
66                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67                                        2000.0 as f64,
68                                    ),
69                                    SyntheticsAssertionType::RESPONSE_TIME,
70                                ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71                            ),
72                        ),
73                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74                            Box::new(
75                                SyntheticsAssertionJSONPathTarget::new(
76                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77                                    SyntheticsAssertionType::BODY,
78                                ).target(
79                                    SyntheticsAssertionJSONPathTargetTarget::new()
80                                        .json_path("topKey".to_string())
81                                        .operator("isNot".to_string())
82                                        .target_value(
83                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84                                                "0".to_string(),
85                                            ),
86                                        ),
87                                ),
88                            ),
89                        ),
90                        SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91                            Box::new(
92                                SyntheticsAssertionJSONPathTarget::new(
93                                    SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94                                    SyntheticsAssertionType::BODY,
95                                ).target(
96                                    SyntheticsAssertionJSONPathTargetTarget::new()
97                                        .elements_operator("atLeastOneElementMatches".to_string())
98                                        .json_path("topKey".to_string())
99                                        .operator("isNot".to_string())
100                                        .target_value(
101                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102                                                "0".to_string(),
103                                            ),
104                                        ),
105                                ),
106                            ),
107                        ),
108                        SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109                            Box::new(
110                                SyntheticsAssertionJSONSchemaTarget::new(
111                                    SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112                                    SyntheticsAssertionType::BODY,
113                                ).target(
114                                    SyntheticsAssertionJSONSchemaTargetTarget::new()
115                                        .json_schema(
116                                            r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117                                        )
118                                        .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119                                ),
120                            ),
121                        ),
122                        SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123                            Box::new(
124                                SyntheticsAssertionXPathTarget::new(
125                                    SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126                                    SyntheticsAssertionType::BODY,
127                                ).target(
128                                    SyntheticsAssertionXPathTargetTarget::new()
129                                        .operator("contains".to_string())
130                                        .target_value(
131                                            SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132                                                "0".to_string(),
133                                            ),
134                                        )
135                                        .x_path("target-xpath".to_string()),
136                                ),
137                            ),
138                        ),
139                        SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140                            Box::new(
141                                SyntheticsAssertionBodyHashTarget::new(
142                                    SyntheticsAssertionBodyHashOperator::MD5,
143                                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144                                        "a".to_string(),
145                                    ),
146                                    SyntheticsAssertionBodyHashType::BODY_HASH,
147                                ),
148                            ),
149                        ),
150                        SyntheticsAssertion::SyntheticsAssertionJavascript(
151                            Box::new(
152                                SyntheticsAssertionJavascript::new(
153                                    "const hello = 'world';".to_string(),
154                                    SyntheticsAssertionJavascriptType::JAVASCRIPT,
155                                ),
156                            ),
157                        )
158                    ],
159                )
160                .config_variables(
161                    vec![
162                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163                            .example("content-type".to_string())
164                            .pattern("content-type".to_string())
165                    ],
166                )
167                .request(
168                    SyntheticsTestRequest::new()
169                        .basic_auth(
170                            SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171                                Box::new(
172                                    SyntheticsBasicAuthOauthClient::new(
173                                        "https://datadog-token.com".to_string(),
174                                        "client-id".to_string(),
175                                        "client-secret".to_string(),
176                                        SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177                                        SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178                                    )
179                                        .audience("audience".to_string())
180                                        .resource("resource".to_string())
181                                        .scope("yoyo".to_string()),
182                                ),
183                            ),
184                        )
185                        .certificate(
186                            SyntheticsTestRequestCertificate::new()
187                                .cert(
188                                    SyntheticsTestRequestCertificateItem::new()
189                                        .content("cert-content".to_string())
190                                        .filename("cert-filename".to_string())
191                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192                                )
193                                .key(
194                                    SyntheticsTestRequestCertificateItem::new()
195                                        .content("key-content".to_string())
196                                        .filename("key-filename".to_string())
197                                        .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198                                ),
199                        )
200                        .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201                        .method("GET".to_string())
202                        .persist_cookies(true)
203                        .proxy(
204                            SyntheticsTestRequestProxy::new(
205                                "https://datadoghq.com".to_string(),
206                            ).headers(BTreeMap::from([])),
207                        )
208                        .timeout(10.0 as f64)
209                        .url("https://datadoghq.com".to_string()),
210                )
211                .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212            vec!["aws:us-east-2".to_string()],
213            "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214            "Example-Synthetic".to_string(),
215            SyntheticsTestOptions::new()
216                .accept_self_signed(false)
217                .allow_insecure(true)
218                .follow_redirects(true)
219                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220                .min_failure_duration(10)
221                .min_location_failed(1)
222                .monitor_name("Example-Synthetic".to_string())
223                .monitor_priority(5)
224                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225                .tick_every(60),
226            SyntheticsAPITestType::API,
227        )
228            .subtype(SyntheticsTestDetailsSubType::HTTP)
229            .tags(vec!["testing:api".to_string()]);
230    let configuration = datadog::Configuration::new();
231    let api = SyntheticsAPI::with_config(configuration);
232    let resp = api.create_synthetics_api_test(body).await;
233    if let Ok(value) = resp {
234        println!("{:#?}", value);
235    } else {
236        println!("{:#?}", resp.unwrap_err());
237    }
238}
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 72)
38async fn main() {
39    let body =
40        SyntheticsAPITest::new(
41            SyntheticsAPITestConfig::new()
42                .config_variables(
43                    vec![
44                        SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
45                            .example("content-type".to_string())
46                            .pattern("content-type".to_string())
47                    ],
48                )
49                .steps(
50                    vec![
51                        SyntheticsAPIStep::SyntheticsAPITestStep(
52                            Box::new(
53                                SyntheticsAPITestStep::new(
54                                    vec![
55                                        SyntheticsAssertion::SyntheticsAssertionTarget(
56                                            Box::new(
57                                                SyntheticsAssertionTarget::new(
58                                                    SyntheticsAssertionOperator::IS,
59                                                    SyntheticsAssertionTargetValue
60                                                    ::SyntheticsAssertionTargetValueNumber(
61                                                        200.0 as f64,
62                                                    ),
63                                                    SyntheticsAssertionType::STATUS_CODE,
64                                                ),
65                                            ),
66                                        )
67                                    ],
68                                    "request is sent".to_string(),
69                                    SyntheticsTestRequest::new()
70                                        .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
71                                        .method("GET".to_string())
72                                        .timeout(10.0 as f64)
73                                        .url("https://datadoghq.com".to_string()),
74                                    SyntheticsAPITestStepSubtype::HTTP,
75                                )
76                                    .allow_failure(true)
77                                    .exit_if_succeed(true)
78                                    .extracted_values(
79                                        vec![
80                                            SyntheticsParsingOptions::new()
81                                                .field("server".to_string())
82                                                .name("EXTRACTED_VALUE".to_string())
83                                                .parser(
84                                                    SyntheticsVariableParser::new(
85                                                        SyntheticsGlobalVariableParserType::RAW,
86                                                    ),
87                                                )
88                                                .secure(true)
89                                                .type_(SyntheticsLocalVariableParsingOptionsType::HTTP_HEADER)
90                                        ],
91                                    )
92                                    .extracted_values_from_script(
93                                        "dd.variable.set('STATUS_CODE', dd.response.statusCode);".to_string(),
94                                    )
95                                    .is_critical(true)
96                                    .retry(SyntheticsTestOptionsRetry::new().count(5).interval(1000.0 as f64)),
97                            ),
98                        ),
99                        SyntheticsAPIStep::SyntheticsAPIWaitStep(
100                            Box::new(
101                                SyntheticsAPIWaitStep::new("Wait".to_string(), SyntheticsAPIWaitStepSubtype::WAIT, 1),
102                            ),
103                        ),
104                        SyntheticsAPIStep::SyntheticsAPITestStep(
105                            Box::new(
106                                SyntheticsAPITestStep::new(
107                                    vec![
108                                        SyntheticsAssertion::SyntheticsAssertionTarget(
109                                            Box::new(
110                                                SyntheticsAssertionTarget::new(
111                                                    SyntheticsAssertionOperator::LESS_THAN,
112                                                    SyntheticsAssertionTargetValue
113                                                    ::SyntheticsAssertionTargetValueNumber(
114                                                        1000.0 as f64,
115                                                    ),
116                                                    SyntheticsAssertionType::RESPONSE_TIME,
117                                                ),
118                                            ),
119                                        )
120                                    ],
121                                    "GRPC CALL".to_string(),
122                                    SyntheticsTestRequest::new()
123                                        .call_type(SyntheticsTestCallType::UNARY)
124                                        .compressed_json_descriptor(
125                                            "eJy1lU1z2yAQhv+Lzj74I3ETH506bQ7OZOSm1w4Wa4epBARQppqM/3v5koCJJdvtxCdW77vPssCO3zMKUgHOFu/ZXvBiS6hZho/f8qe7pftYgXphWJrlA8XwxywEvNba+6PhkC2yVcVVswYp0R6ykRYlZ1SCV21SDrxsssPIeS9FJKqGfK2rqnmmSBwhWa2XlKgtaQPiDcRGCUDVfwGD2sKUqKEtc1cSoOrsMlaMOec1sySYCCgUYRSVLv2zSva2u+FQkB0pVkIw8bFuIudOOn3pOaKYVT3Iy97Pd0AYhOx5QcMsnxvRHlnuLf8ETDd3CNtrv2nejkDpRnANCmGkkFn/hsYzpBKE7jVbufgnKnV9HRM9zRPDDKPttYT61n0TdWkAAjggk9AhuxIeaXd69CYTcsGw7cBTakLVbNpRzGEgyWjkSOpMbZXkhGL6oX30R49qt3GoHrap7i0XdD41WQ+2icCNm5p1hmFqnHNlcla0riKmDZ183crDxChjbnurtxHPRE784sVhWvDfGP+SsTKibU3o5NtWHuZFGZOxP6P5VXqIOvaOSec4eYohyd7NslHuJbd1bewds85xYrNxkr2d+5IhFWF3NvaO684xjE2S5ulY+tu64Pna0fCPJgzw6vF5/WucLcYjt5xoq19O3UDptOg/OamJQRaCcPPnMTQ2QDFn+uhPvUfnCrMc99upyQY4Ui9Dlc/YoG3R/v4Cs9YE+g==".to_string(),
126                                        )
127                                        .host("grpcbin.test.k6.io".to_string())
128                                        .message("{}".to_string())
129                                        .metadata(BTreeMap::from([]))
130                                        .method("Index".to_string())
131                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(9000))
132                                        .service("grpcbin.GRPCBin".to_string()),
133                                    SyntheticsAPITestStepSubtype::GRPC,
134                                )
135                                    .allow_failure(false)
136                                    .extracted_values(vec![])
137                                    .is_critical(true)
138                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
139                            ),
140                        ),
141                        SyntheticsAPIStep::SyntheticsAPITestStep(
142                            Box::new(
143                                SyntheticsAPITestStep::new(
144                                    vec![
145                                        SyntheticsAssertion::SyntheticsAssertionTarget(
146                                            Box::new(
147                                                SyntheticsAssertionTarget::new(
148                                                    SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
149                                                    SyntheticsAssertionTargetValue
150                                                    ::SyntheticsAssertionTargetValueNumber(
151                                                        10.0 as f64,
152                                                    ),
153                                                    SyntheticsAssertionType::CERTIFICATE,
154                                                ),
155                                            ),
156                                        )
157                                    ],
158                                    "SSL step".to_string(),
159                                    SyntheticsTestRequest::new()
160                                        .check_certificate_revocation(true)
161                                        .disable_aia_intermediate_fetching(true)
162                                        .host("example.org".to_string())
163                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
164                                    SyntheticsAPITestStepSubtype::SSL,
165                                )
166                                    .allow_failure(false)
167                                    .is_critical(true)
168                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
169                            ),
170                        ),
171                        SyntheticsAPIStep::SyntheticsAPITestStep(
172                            Box::new(
173                                SyntheticsAPITestStep::new(
174                                    vec![
175                                        SyntheticsAssertion::SyntheticsAssertionTarget(
176                                            Box::new(
177                                                SyntheticsAssertionTarget::new(
178                                                    SyntheticsAssertionOperator::LESS_THAN,
179                                                    SyntheticsAssertionTargetValue
180                                                    ::SyntheticsAssertionTargetValueNumber(
181                                                        1000.0 as f64,
182                                                    ),
183                                                    SyntheticsAssertionType::RESPONSE_TIME,
184                                                ),
185                                            ),
186                                        )
187                                    ],
188                                    "DNS step".to_string(),
189                                    SyntheticsTestRequest::new()
190                                        .dns_server("8.8.8.8".to_string())
191                                        .dns_server_port(
192                                            SyntheticsTestRequestDNSServerPort
193                                            ::SyntheticsTestRequestVariableDNSServerPort(
194                                                "53".to_string(),
195                                            ),
196                                        )
197                                        .host("troisdizaines.com".to_string()),
198                                    SyntheticsAPITestStepSubtype::DNS,
199                                )
200                                    .allow_failure(false)
201                                    .is_critical(true)
202                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
203                            ),
204                        ),
205                        SyntheticsAPIStep::SyntheticsAPITestStep(
206                            Box::new(
207                                SyntheticsAPITestStep::new(
208                                    vec![
209                                        SyntheticsAssertion::SyntheticsAssertionTarget(
210                                            Box::new(
211                                                SyntheticsAssertionTarget::new(
212                                                    SyntheticsAssertionOperator::LESS_THAN,
213                                                    SyntheticsAssertionTargetValue
214                                                    ::SyntheticsAssertionTargetValueNumber(
215                                                        1000.0 as f64,
216                                                    ),
217                                                    SyntheticsAssertionType::RESPONSE_TIME,
218                                                ),
219                                            ),
220                                        )
221                                    ],
222                                    "TCP step".to_string(),
223                                    SyntheticsTestRequest::new()
224                                        .host("34.95.79.70".to_string())
225                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
226                                        .should_track_hops(true)
227                                        .timeout(32.0 as f64),
228                                    SyntheticsAPITestStepSubtype::TCP,
229                                )
230                                    .allow_failure(false)
231                                    .is_critical(true)
232                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
233                            ),
234                        ),
235                        SyntheticsAPIStep::SyntheticsAPITestStep(
236                            Box::new(
237                                SyntheticsAPITestStep::new(
238                                    vec![
239                                        SyntheticsAssertion::SyntheticsAssertionTarget(
240                                            Box::new(
241                                                SyntheticsAssertionTarget::new(
242                                                    SyntheticsAssertionOperator::IS,
243                                                    SyntheticsAssertionTargetValue
244                                                    ::SyntheticsAssertionTargetValueNumber(
245                                                        0.0 as f64,
246                                                    ),
247                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
248                                                ),
249                                            ),
250                                        )
251                                    ],
252                                    "ICMP step".to_string(),
253                                    SyntheticsTestRequest::new()
254                                        .host("34.95.79.70".to_string())
255                                        .number_of_packets(4)
256                                        .should_track_hops(true)
257                                        .timeout(38.0 as f64),
258                                    SyntheticsAPITestStepSubtype::ICMP,
259                                )
260                                    .allow_failure(false)
261                                    .is_critical(true)
262                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
263                            ),
264                        ),
265                        SyntheticsAPIStep::SyntheticsAPITestStep(
266                            Box::new(
267                                SyntheticsAPITestStep::new(
268                                    vec![
269                                        SyntheticsAssertion::SyntheticsAssertionTarget(
270                                            Box::new(
271                                                SyntheticsAssertionTarget::new(
272                                                    SyntheticsAssertionOperator::LESS_THAN,
273                                                    SyntheticsAssertionTargetValue
274                                                    ::SyntheticsAssertionTargetValueNumber(
275                                                        1000.0 as f64,
276                                                    ),
277                                                    SyntheticsAssertionType::RESPONSE_TIME,
278                                                ),
279                                            ),
280                                        )
281                                    ],
282                                    "Websocket step".to_string(),
283                                    SyntheticsTestRequest::new()
284                                        .basic_auth(
285                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
286                                                Box::new(
287                                                    SyntheticsBasicAuthWeb::new()
288                                                        .password("password".to_string())
289                                                        .type_(SyntheticsBasicAuthWebType::WEB)
290                                                        .username("user".to_string()),
291                                                ),
292                                            ),
293                                        )
294                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
295                                        .is_message_base64_encoded(true)
296                                        .message("My message".to_string())
297                                        .url("ws://34.95.79.70/web-socket".to_string()),
298                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
299                                )
300                                    .allow_failure(false)
301                                    .is_critical(true)
302                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
303                            ),
304                        ),
305                        SyntheticsAPIStep::SyntheticsAPITestStep(
306                            Box::new(
307                                SyntheticsAPITestStep::new(
308                                    vec![
309                                        SyntheticsAssertion::SyntheticsAssertionTarget(
310                                            Box::new(
311                                                SyntheticsAssertionTarget::new(
312                                                    SyntheticsAssertionOperator::LESS_THAN,
313                                                    SyntheticsAssertionTargetValue
314                                                    ::SyntheticsAssertionTargetValueNumber(
315                                                        1000.0 as f64,
316                                                    ),
317                                                    SyntheticsAssertionType::RESPONSE_TIME,
318                                                ),
319                                            ),
320                                        )
321                                    ],
322                                    "UDP step".to_string(),
323                                    SyntheticsTestRequest::new()
324                                        .host("8.8.8.8".to_string())
325                                        .message("A image.google.com".to_string())
326                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
327                                    SyntheticsAPITestStepSubtype::UDP,
328                                )
329                                    .allow_failure(false)
330                                    .is_critical(true)
331                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
332                            ),
333                        )
334                    ],
335                ),
336            vec!["aws:us-east-2".to_string()],
337            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
338            "Example-Synthetic".to_string(),
339            SyntheticsTestOptions::new()
340                .accept_self_signed(false)
341                .allow_insecure(true)
342                .follow_redirects(true)
343                .min_failure_duration(10)
344                .min_location_failed(1)
345                .monitor_name("Example-Synthetic".to_string())
346                .monitor_priority(5)
347                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
348                .tick_every(60),
349            SyntheticsAPITestType::API,
350        )
351            .subtype(SyntheticsTestDetailsSubType::MULTI)
352            .tags(vec!["testing:api".to_string()]);
353    let configuration = datadog::Configuration::new();
354    let api = SyntheticsAPI::with_config(configuration);
355    let resp = api.create_synthetics_api_test(body).await;
356    if let Ok(value) = resp {
357        println!("{:#?}", value);
358    } else {
359        println!("{:#?}", resp.unwrap_err());
360    }
361}
Source

pub fn url(self, value: String) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsBrowserTest.rs (line 25)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsBrowserTest_2932742688.rs (line 27)
20async fn main() {
21    let body = SyntheticsBrowserTest::new(
22        SyntheticsBrowserTestConfig::new(
23            vec![],
24            SyntheticsTestRequest::new()
25                .certificate_domains(vec!["https://datadoghq.com".to_string()])
26                .method("GET".to_string())
27                .url("https://datadoghq.com".to_string()),
28        )
29        .config_variables(vec![SyntheticsConfigVariable::new(
30            "PROPERTY".to_string(),
31            SyntheticsConfigVariableType::TEXT,
32        )
33        .example("content-type".to_string())
34        .pattern("content-type".to_string())])
35        .set_cookie("name:test".to_string()),
36        vec!["aws:us-east-2".to_string()],
37        "Test message".to_string(),
38        "Example-Synthetic".to_string(),
39        SyntheticsTestOptions::new()
40            .accept_self_signed(false)
41            .allow_insecure(true)
42            .ci(SyntheticsTestCiOptions::new(
43                SyntheticsTestExecutionRule::SKIPPED,
44            ))
45            .device_ids(vec!["tablet".to_string()])
46            .disable_cors(true)
47            .disable_csp(true)
48            .follow_redirects(true)
49            .ignore_server_certificate_error(true)
50            .initial_navigation_timeout(200)
51            .min_failure_duration(10)
52            .min_location_failed(1)
53            .no_screenshot(true)
54            .retry(
55                SyntheticsTestOptionsRetry::new()
56                    .count(2)
57                    .interval(10.0 as f64),
58            )
59            .rum_settings(
60                SyntheticsBrowserTestRumSettings::new(true)
61                    .application_id("mockApplicationId".to_string())
62                    .client_token_id(12345),
63            )
64            .tick_every(300),
65        SyntheticsBrowserTestType::BROWSER,
66    )
67    .steps(vec![SyntheticsStep::new()
68        .allow_failure(false)
69        .is_critical(true)
70        .name("Refresh page".to_string())
71        .params(BTreeMap::new())
72        .type_(SyntheticsStepType::REFRESH)])
73    .tags(vec!["testing:browser".to_string()]);
74    let configuration = datadog::Configuration::new();
75    let api = SyntheticsAPI::with_config(configuration);
76    let resp = api.create_synthetics_browser_test(body).await;
77    if let Ok(value) = resp {
78        println!("{:#?}", value);
79    } else {
80        println!("{:#?}", resp.unwrap_err());
81    }
82}
examples/v1_synthetics_CreateSyntheticsAPITest_2472747642.rs (line 46)
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}
examples/v1_synthetics_CreateSyntheticsBrowserTest_397420811.rs (line 26)
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}
examples/v1_synthetics_CreateSyntheticsAPITest.rs (line 42)
27async fn main() {
28    let body = SyntheticsAPITest::new(
29        SyntheticsAPITestConfig::new()
30            .assertions(vec![SyntheticsAssertion::SyntheticsAssertionTarget(
31                Box::new(SyntheticsAssertionTarget::new(
32                    SyntheticsAssertionOperator::LESS_THAN,
33                    SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
34                        1000.0 as f64,
35                    ),
36                    SyntheticsAssertionType::RESPONSE_TIME,
37                )),
38            )])
39            .request(
40                SyntheticsTestRequest::new()
41                    .method("GET".to_string())
42                    .url("https://example.com".to_string()),
43            ),
44        vec!["aws:eu-west-3".to_string()],
45        "Notification message".to_string(),
46        "Example test name".to_string(),
47        SyntheticsTestOptions::new()
48            .ci(SyntheticsTestCiOptions::new(
49                SyntheticsTestExecutionRule::BLOCKING,
50            ))
51            .device_ids(vec!["chrome.laptop_large".to_string()])
52            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
53            .monitor_options(
54                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
55                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
56                ),
57            )
58            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
59            .retry(SyntheticsTestOptionsRetry::new())
60            .rum_settings(
61                SyntheticsBrowserTestRumSettings::new(true)
62                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
63                    .client_token_id(12345),
64            )
65            .scheduling(SyntheticsTestOptionsScheduling::new(
66                vec![
67                    SyntheticsTestOptionsSchedulingTimeframe::new(
68                        1,
69                        "07:00".to_string(),
70                        "16:00".to_string(),
71                    ),
72                    SyntheticsTestOptionsSchedulingTimeframe::new(
73                        3,
74                        "07:00".to_string(),
75                        "16:00".to_string(),
76                    ),
77                ],
78                "America/New_York".to_string(),
79            )),
80        SyntheticsAPITestType::API,
81    )
82    .status(SyntheticsTestPauseStatus::LIVE)
83    .subtype(SyntheticsTestDetailsSubType::HTTP)
84    .tags(vec!["env:production".to_string()]);
85    let configuration = datadog::Configuration::new();
86    let api = SyntheticsAPI::with_config(configuration);
87    let resp = api.create_synthetics_api_test(body).await;
88    if let Ok(value) = resp {
89        println!("{:#?}", value);
90    } else {
91        println!("{:#?}", resp.unwrap_err());
92    }
93}
examples/v1_synthetics_UpdateBrowserTest.rs (line 61)
36async fn main() {
37    let body = SyntheticsBrowserTest::new(
38        SyntheticsBrowserTestConfig::new(
39            vec![],
40            SyntheticsTestRequest::new()
41                .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
42                    SyntheticsBasicAuthWeb::new()
43                        .password("PaSSw0RD!".to_string())
44                        .type_(SyntheticsBasicAuthWebType::WEB)
45                        .username("my_username".to_string()),
46                )))
47                .body_type(SyntheticsTestRequestBodyType::TEXT_PLAIN)
48                .call_type(SyntheticsTestCallType::UNARY)
49                .certificate(
50                    SyntheticsTestRequestCertificate::new()
51                        .cert(SyntheticsTestRequestCertificateItem::new())
52                        .key(SyntheticsTestRequestCertificateItem::new()),
53                )
54                .certificate_domains(vec![])
55                .files(vec![SyntheticsTestRequestBodyFile::new()])
56                .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
57                .proxy(SyntheticsTestRequestProxy::new(
58                    "https://example.com".to_string(),
59                ))
60                .service("Greeter".to_string())
61                .url("https://example.com".to_string()),
62        )
63        .config_variables(vec![SyntheticsConfigVariable::new(
64            "VARIABLE_NAME".to_string(),
65            SyntheticsConfigVariableType::TEXT,
66        )
67        .secure(false)])
68        .variables(vec![SyntheticsBrowserVariable::new(
69            "VARIABLE_NAME".to_string(),
70            SyntheticsBrowserVariableType::TEXT,
71        )]),
72        vec!["aws:eu-west-3".to_string()],
73        "".to_string(),
74        "Example test name".to_string(),
75        SyntheticsTestOptions::new()
76            .ci(SyntheticsTestCiOptions::new(
77                SyntheticsTestExecutionRule::BLOCKING,
78            ))
79            .device_ids(vec!["chrome.laptop_large".to_string()])
80            .http_version(SyntheticsTestOptionsHTTPVersion::HTTP1)
81            .monitor_options(
82                SyntheticsTestOptionsMonitorOptions::new().notification_preset_name(
83                    SyntheticsTestOptionsMonitorOptionsNotificationPresetName::SHOW_ALL,
84                ),
85            )
86            .restricted_roles(vec!["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string()])
87            .retry(SyntheticsTestOptionsRetry::new())
88            .rum_settings(
89                SyntheticsBrowserTestRumSettings::new(true)
90                    .application_id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".to_string())
91                    .client_token_id(12345),
92            )
93            .scheduling(SyntheticsTestOptionsScheduling::new(
94                vec![
95                    SyntheticsTestOptionsSchedulingTimeframe::new(
96                        1,
97                        "07:00".to_string(),
98                        "16:00".to_string(),
99                    ),
100                    SyntheticsTestOptionsSchedulingTimeframe::new(
101                        3,
102                        "07:00".to_string(),
103                        "16:00".to_string(),
104                    ),
105                ],
106                "America/New_York".to_string(),
107            )),
108        SyntheticsBrowserTestType::BROWSER,
109    )
110    .status(SyntheticsTestPauseStatus::LIVE)
111    .steps(vec![
112        SyntheticsStep::new().type_(SyntheticsStepType::ASSERT_ELEMENT_CONTENT)
113    ])
114    .tags(vec!["env:prod".to_string()]);
115    let configuration = datadog::Configuration::new();
116    let api = SyntheticsAPI::with_config(configuration);
117    let resp = api.update_browser_test("public_id".to_string(), body).await;
118    if let Ok(value) = resp {
119        println!("{:#?}", value);
120    } else {
121        println!("{:#?}", resp.unwrap_err());
122    }
123}
Source

pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self

Trait Implementations§

Source§

impl Clone for SyntheticsTestRequest

Source§

fn clone(&self) -> SyntheticsTestRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntheticsTestRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SyntheticsTestRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SyntheticsTestRequest

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SyntheticsTestRequest

Source§

fn eq(&self, other: &SyntheticsTestRequest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SyntheticsTestRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SyntheticsTestRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,