Struct SyntheticsAPITestStep

Source
#[non_exhaustive]
pub struct SyntheticsAPITestStep { pub allow_failure: Option<bool>, pub assertions: Vec<SyntheticsAssertion>, pub exit_if_succeed: Option<bool>, pub extracted_values: Option<Vec<SyntheticsParsingOptions>>, pub extracted_values_from_script: Option<String>, pub is_critical: Option<bool>, pub name: String, pub request: SyntheticsTestRequest, pub retry: Option<SyntheticsTestOptionsRetry>, pub subtype: SyntheticsAPITestStepSubtype, pub additional_properties: BTreeMap<String, Value>, /* private fields */ }
Expand description

The Test step used in a Synthetic multi-step API test.

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_failure: Option<bool>

Determines whether or not to continue with test if this step fails.

§assertions: Vec<SyntheticsAssertion>

Array of assertions used for the test.

§exit_if_succeed: Option<bool>

Determines whether or not to exit the test if the step succeeds.

§extracted_values: Option<Vec<SyntheticsParsingOptions>>

Array of values to parse and save as variables from the response.

§extracted_values_from_script: Option<String>

Generate variables using JavaScript.

§is_critical: Option<bool>

Determines whether or not to consider the entire test as failed if this step fails. Can be used only if allowFailure is true.

§name: String

The name of the step.

§request: SyntheticsTestRequest

Object describing the Synthetic test request.

§retry: Option<SyntheticsTestOptionsRetry>

Object describing the retry strategy to apply to a Synthetic test.

§subtype: SyntheticsAPITestStepSubtype

The subtype of the Synthetic multi-step API test step.

§additional_properties: BTreeMap<String, Value>

Implementations§

Source§

impl SyntheticsAPITestStep

Source

pub fn new( assertions: Vec<SyntheticsAssertion>, name: String, request: SyntheticsTestRequest, subtype: SyntheticsAPITestStepSubtype, ) -> SyntheticsAPITestStep

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1717840259.rs (lines 38-58)
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}
More examples
Hide additional examples
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (lines 53-75)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

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

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 76)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

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

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 77)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

pub fn extracted_values(self, value: Vec<SyntheticsParsingOptions>) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (lines 78-91)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

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

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (lines 92-94)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

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

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 95)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

pub fn retry(self, value: SyntheticsTestOptionsRetry) -> Self

Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1279271422.rs (line 96)
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                                        .host("example.org".to_string())
162                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(443)),
163                                    SyntheticsAPITestStepSubtype::SSL,
164                                )
165                                    .allow_failure(false)
166                                    .is_critical(true)
167                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
168                            ),
169                        ),
170                        SyntheticsAPIStep::SyntheticsAPITestStep(
171                            Box::new(
172                                SyntheticsAPITestStep::new(
173                                    vec![
174                                        SyntheticsAssertion::SyntheticsAssertionTarget(
175                                            Box::new(
176                                                SyntheticsAssertionTarget::new(
177                                                    SyntheticsAssertionOperator::LESS_THAN,
178                                                    SyntheticsAssertionTargetValue
179                                                    ::SyntheticsAssertionTargetValueNumber(
180                                                        1000.0 as f64,
181                                                    ),
182                                                    SyntheticsAssertionType::RESPONSE_TIME,
183                                                ),
184                                            ),
185                                        )
186                                    ],
187                                    "DNS step".to_string(),
188                                    SyntheticsTestRequest::new()
189                                        .dns_server("8.8.8.8".to_string())
190                                        .dns_server_port(
191                                            SyntheticsTestRequestDNSServerPort
192                                            ::SyntheticsTestRequestVariableDNSServerPort(
193                                                "53".to_string(),
194                                            ),
195                                        )
196                                        .host("troisdizaines.com".to_string()),
197                                    SyntheticsAPITestStepSubtype::DNS,
198                                )
199                                    .allow_failure(false)
200                                    .is_critical(true)
201                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
202                            ),
203                        ),
204                        SyntheticsAPIStep::SyntheticsAPITestStep(
205                            Box::new(
206                                SyntheticsAPITestStep::new(
207                                    vec![
208                                        SyntheticsAssertion::SyntheticsAssertionTarget(
209                                            Box::new(
210                                                SyntheticsAssertionTarget::new(
211                                                    SyntheticsAssertionOperator::LESS_THAN,
212                                                    SyntheticsAssertionTargetValue
213                                                    ::SyntheticsAssertionTargetValueNumber(
214                                                        1000.0 as f64,
215                                                    ),
216                                                    SyntheticsAssertionType::RESPONSE_TIME,
217                                                ),
218                                            ),
219                                        )
220                                    ],
221                                    "TCP step".to_string(),
222                                    SyntheticsTestRequest::new()
223                                        .host("34.95.79.70".to_string())
224                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(80))
225                                        .should_track_hops(true)
226                                        .timeout(32.0 as f64),
227                                    SyntheticsAPITestStepSubtype::TCP,
228                                )
229                                    .allow_failure(false)
230                                    .is_critical(true)
231                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
232                            ),
233                        ),
234                        SyntheticsAPIStep::SyntheticsAPITestStep(
235                            Box::new(
236                                SyntheticsAPITestStep::new(
237                                    vec![
238                                        SyntheticsAssertion::SyntheticsAssertionTarget(
239                                            Box::new(
240                                                SyntheticsAssertionTarget::new(
241                                                    SyntheticsAssertionOperator::IS,
242                                                    SyntheticsAssertionTargetValue
243                                                    ::SyntheticsAssertionTargetValueNumber(
244                                                        0.0 as f64,
245                                                    ),
246                                                    SyntheticsAssertionType::PACKET_LOSS_PERCENTAGE,
247                                                ),
248                                            ),
249                                        )
250                                    ],
251                                    "ICMP step".to_string(),
252                                    SyntheticsTestRequest::new()
253                                        .host("34.95.79.70".to_string())
254                                        .number_of_packets(4)
255                                        .should_track_hops(true)
256                                        .timeout(38.0 as f64),
257                                    SyntheticsAPITestStepSubtype::ICMP,
258                                )
259                                    .allow_failure(false)
260                                    .is_critical(true)
261                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
262                            ),
263                        ),
264                        SyntheticsAPIStep::SyntheticsAPITestStep(
265                            Box::new(
266                                SyntheticsAPITestStep::new(
267                                    vec![
268                                        SyntheticsAssertion::SyntheticsAssertionTarget(
269                                            Box::new(
270                                                SyntheticsAssertionTarget::new(
271                                                    SyntheticsAssertionOperator::LESS_THAN,
272                                                    SyntheticsAssertionTargetValue
273                                                    ::SyntheticsAssertionTargetValueNumber(
274                                                        1000.0 as f64,
275                                                    ),
276                                                    SyntheticsAssertionType::RESPONSE_TIME,
277                                                ),
278                                            ),
279                                        )
280                                    ],
281                                    "Websocket step".to_string(),
282                                    SyntheticsTestRequest::new()
283                                        .basic_auth(
284                                            SyntheticsBasicAuth::SyntheticsBasicAuthWeb(
285                                                Box::new(
286                                                    SyntheticsBasicAuthWeb::new()
287                                                        .password("password".to_string())
288                                                        .type_(SyntheticsBasicAuthWebType::WEB)
289                                                        .username("user".to_string()),
290                                                ),
291                                            ),
292                                        )
293                                        .headers(BTreeMap::from([("f".to_string(), "g".to_string())]))
294                                        .is_message_base64_encoded(true)
295                                        .message("My message".to_string())
296                                        .url("ws://34.95.79.70/web-socket".to_string()),
297                                    SyntheticsAPITestStepSubtype::WEBSOCKET,
298                                )
299                                    .allow_failure(false)
300                                    .is_critical(true)
301                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
302                            ),
303                        ),
304                        SyntheticsAPIStep::SyntheticsAPITestStep(
305                            Box::new(
306                                SyntheticsAPITestStep::new(
307                                    vec![
308                                        SyntheticsAssertion::SyntheticsAssertionTarget(
309                                            Box::new(
310                                                SyntheticsAssertionTarget::new(
311                                                    SyntheticsAssertionOperator::LESS_THAN,
312                                                    SyntheticsAssertionTargetValue
313                                                    ::SyntheticsAssertionTargetValueNumber(
314                                                        1000.0 as f64,
315                                                    ),
316                                                    SyntheticsAssertionType::RESPONSE_TIME,
317                                                ),
318                                            ),
319                                        )
320                                    ],
321                                    "UDP step".to_string(),
322                                    SyntheticsTestRequest::new()
323                                        .host("8.8.8.8".to_string())
324                                        .message("A image.google.com".to_string())
325                                        .port(SyntheticsTestRequestPort::SyntheticsTestRequestNumericalPort(53)),
326                                    SyntheticsAPITestStepSubtype::UDP,
327                                )
328                                    .allow_failure(false)
329                                    .is_critical(true)
330                                    .retry(SyntheticsTestOptionsRetry::new().count(0).interval(300.0 as f64)),
331                            ),
332                        )
333                    ],
334                ),
335            vec!["aws:us-east-2".to_string()],
336            "BDD test payload: synthetics_api_test_multi_step_payload.json".to_string(),
337            "Example-Synthetic".to_string(),
338            SyntheticsTestOptions::new()
339                .accept_self_signed(false)
340                .allow_insecure(true)
341                .follow_redirects(true)
342                .min_failure_duration(10)
343                .min_location_failed(1)
344                .monitor_name("Example-Synthetic".to_string())
345                .monitor_priority(5)
346                .retry(SyntheticsTestOptionsRetry::new().count(3).interval(1000.0 as f64))
347                .tick_every(60),
348            SyntheticsAPITestType::API,
349        )
350            .subtype(SyntheticsTestDetailsSubType::MULTI)
351            .tags(vec!["testing:api".to_string()]);
352    let configuration = datadog::Configuration::new();
353    let api = SyntheticsAPI::with_config(configuration);
354    let resp = api.create_synthetics_api_test(body).await;
355    if let Ok(value) = resp {
356        println!("{:#?}", value);
357    } else {
358        println!("{:#?}", resp.unwrap_err());
359    }
360}
Source

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

Trait Implementations§

Source§

impl Clone for SyntheticsAPITestStep

Source§

fn clone(&self) -> SyntheticsAPITestStep

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 SyntheticsAPITestStep

Source§

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

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

impl<'de> Deserialize<'de> for SyntheticsAPITestStep

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 SyntheticsAPITestStep

Source§

fn eq(&self, other: &SyntheticsAPITestStep) -> 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 SyntheticsAPITestStep

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 SyntheticsAPITestStep

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,