#[non_exhaustive]pub struct SyntheticsBasicAuthOauthClient {
pub access_token_url: String,
pub audience: Option<String>,
pub client_id: String,
pub client_secret: String,
pub resource: Option<String>,
pub scope: Option<String>,
pub token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
pub type_: SyntheticsBasicAuthOauthClientType,
pub additional_properties: BTreeMap<String, Value>,
/* private fields */
}
Expand description
Object to handle oauth client
authentication when performing the 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.access_token_url: String
Access token URL to use when performing the authentication.
audience: Option<String>
Audience to use when performing the authentication.
client_id: String
Client ID to use when performing the authentication.
client_secret: String
Client secret to use when performing the authentication.
resource: Option<String>
Resource to use when performing the authentication.
scope: Option<String>
Scope to use when performing the authentication.
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication
Type of token to use when performing the authentication.
type_: SyntheticsBasicAuthOauthClientType
The type of basic authentication to use when performing the test.
additional_properties: BTreeMap<String, Value>
Implementations§
Source§impl SyntheticsBasicAuthOauthClient
impl SyntheticsBasicAuthOauthClient
Sourcepub fn new(
access_token_url: String,
client_id: String,
client_secret: String,
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
type_: SyntheticsBasicAuthOauthClientType,
) -> SyntheticsBasicAuthOauthClient
pub fn new( access_token_url: String, client_id: String, client_secret: String, token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication, type_: SyntheticsBasicAuthOauthClientType, ) -> SyntheticsBasicAuthOauthClient
Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (lines 115-121)
39async fn main() {
40 let body =
41 SyntheticsAPITest::new(
42 SyntheticsAPITestConfig::new()
43 .assertions(
44 vec![
45 SyntheticsAssertion::SyntheticsAssertionTarget(
46 Box::new(
47 SyntheticsAssertionTarget::new(
48 SyntheticsAssertionOperator::IS,
49 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50 "text/html".to_string(),
51 ),
52 SyntheticsAssertionType::HEADER,
53 ).property("{{ PROPERTY }}".to_string()),
54 ),
55 ),
56 SyntheticsAssertion::SyntheticsAssertionTarget(
57 Box::new(
58 SyntheticsAssertionTarget::new(
59 SyntheticsAssertionOperator::LESS_THAN,
60 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61 2000.0 as f64,
62 ),
63 SyntheticsAssertionType::RESPONSE_TIME,
64 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65 ),
66 ),
67 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68 Box::new(
69 SyntheticsAssertionJSONPathTarget::new(
70 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71 SyntheticsAssertionType::BODY,
72 ).target(
73 SyntheticsAssertionJSONPathTargetTarget::new()
74 .json_path("topKey".to_string())
75 .operator("isNot".to_string())
76 .target_value(
77 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78 "0".to_string(),
79 ),
80 ),
81 ),
82 ),
83 ),
84 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85 Box::new(
86 SyntheticsAssertionXPathTarget::new(
87 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88 SyntheticsAssertionType::BODY,
89 ).target(
90 SyntheticsAssertionXPathTargetTarget::new()
91 .operator("contains".to_string())
92 .target_value(
93 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94 "0".to_string(),
95 ),
96 )
97 .x_path("target-xpath".to_string()),
98 ),
99 ),
100 )
101 ],
102 )
103 .config_variables(
104 vec![
105 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106 .example("content-type".to_string())
107 .pattern("content-type".to_string())
108 ],
109 )
110 .request(
111 SyntheticsTestRequest::new()
112 .basic_auth(
113 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114 Box::new(
115 SyntheticsBasicAuthOauthClient::new(
116 "https://datadog-token.com".to_string(),
117 "client-id".to_string(),
118 "client-secret".to_string(),
119 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121 )
122 .audience("audience".to_string())
123 .resource("resource".to_string())
124 .scope("yoyo".to_string()),
125 ),
126 ),
127 )
128 .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129 .certificate(
130 SyntheticsTestRequestCertificate::new()
131 .cert(
132 SyntheticsTestRequestCertificateItem::new()
133 .content("cert-content".to_string())
134 .filename("cert-filename".to_string())
135 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136 )
137 .key(
138 SyntheticsTestRequestCertificateItem::new()
139 .content("key-content".to_string())
140 .filename("key-filename".to_string())
141 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142 ),
143 )
144 .files(
145 vec![
146 SyntheticsTestRequestBodyFile::new()
147 .content("file content".to_string())
148 .name("file name".to_string())
149 .original_file_name("image.png".to_string())
150 .type_("file type".to_string())
151 ],
152 )
153 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154 .method("GET".to_string())
155 .persist_cookies(true)
156 .proxy(
157 SyntheticsTestRequestProxy::new(
158 "https://datadoghq.com".to_string(),
159 ).headers(BTreeMap::from([])),
160 )
161 .timeout(10.0 as f64)
162 .url("https://datadoghq.com".to_string()),
163 ),
164 vec!["aws:us-east-2".to_string()],
165 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166 "Example-Synthetic".to_string(),
167 SyntheticsTestOptions::new()
168 .accept_self_signed(false)
169 .allow_insecure(true)
170 .follow_redirects(true)
171 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172 .min_failure_duration(10)
173 .min_location_failed(1)
174 .monitor_name("Example-Synthetic".to_string())
175 .monitor_priority(5)
176 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177 .tick_every(60),
178 SyntheticsAPITestType::API,
179 )
180 .subtype(SyntheticsTestDetailsSubType::HTTP)
181 .tags(vec!["testing:api".to_string()]);
182 let configuration = datadog::Configuration::new();
183 let api = SyntheticsAPI::with_config(configuration);
184 let resp = api.create_synthetics_api_test(body).await;
185 if let Ok(value) = resp {
186 println!("{:#?}", value);
187 } else {
188 println!("{:#?}", resp.unwrap_err());
189 }
190}
More examples
examples/v1_synthetics_CreateSyntheticsAPITest_1717840259.rs (lines 159-165)
35async fn main() {
36 let body = SyntheticsAPITest::new(
37 SyntheticsAPITestConfig::new().steps(vec![
38 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
39 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
40 SyntheticsAssertionTarget::new(
41 SyntheticsAssertionOperator::IS,
42 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
43 200.0 as f64,
44 ),
45 SyntheticsAssertionType::STATUS_CODE,
46 ),
47 ))],
48 "request is sent".to_string(),
49 SyntheticsTestRequest::new()
50 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
51 SyntheticsBasicAuthWeb::new()
52 .password("password".to_string())
53 .username("username".to_string()),
54 )))
55 .method("GET".to_string())
56 .url("https://httpbin.org/status/200".to_string()),
57 SyntheticsAPITestStepSubtype::HTTP,
58 ))),
59 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
60 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
61 SyntheticsAssertionTarget::new(
62 SyntheticsAssertionOperator::IS,
63 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
64 200.0 as f64,
65 ),
66 SyntheticsAssertionType::STATUS_CODE,
67 ),
68 ))],
69 "request is sent".to_string(),
70 SyntheticsTestRequest::new()
71 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
72 SyntheticsBasicAuthWeb::new()
73 .password("password".to_string())
74 .type_(SyntheticsBasicAuthWebType::WEB)
75 .username("username".to_string()),
76 )))
77 .method("GET".to_string())
78 .url("https://httpbin.org/status/200".to_string()),
79 SyntheticsAPITestStepSubtype::HTTP,
80 ))),
81 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
82 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
83 SyntheticsAssertionTarget::new(
84 SyntheticsAssertionOperator::IS,
85 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
86 200.0 as f64,
87 ),
88 SyntheticsAssertionType::STATUS_CODE,
89 ),
90 ))],
91 "request is sent".to_string(),
92 SyntheticsTestRequest::new()
93 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthSigv4(Box::new(
94 SyntheticsBasicAuthSigv4::new(
95 "accessKey".to_string(),
96 "secretKey".to_string(),
97 SyntheticsBasicAuthSigv4Type::SIGV4,
98 ),
99 )))
100 .method("GET".to_string())
101 .url("https://httpbin.org/status/200".to_string()),
102 SyntheticsAPITestStepSubtype::HTTP,
103 ))),
104 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
105 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
106 SyntheticsAssertionTarget::new(
107 SyntheticsAssertionOperator::IS,
108 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
109 200.0 as f64,
110 ),
111 SyntheticsAssertionType::STATUS_CODE,
112 ),
113 ))],
114 "request is sent".to_string(),
115 SyntheticsTestRequest::new()
116 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthNTLM(Box::new(
117 SyntheticsBasicAuthNTLM::new(SyntheticsBasicAuthNTLMType::NTLM),
118 )))
119 .method("GET".to_string())
120 .url("https://httpbin.org/status/200".to_string()),
121 SyntheticsAPITestStepSubtype::HTTP,
122 ))),
123 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
124 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
125 SyntheticsAssertionTarget::new(
126 SyntheticsAssertionOperator::IS,
127 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
128 200.0 as f64,
129 ),
130 SyntheticsAssertionType::STATUS_CODE,
131 ),
132 ))],
133 "request is sent".to_string(),
134 SyntheticsTestRequest::new()
135 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthDigest(Box::new(
136 SyntheticsBasicAuthDigest::new(
137 "password".to_string(),
138 SyntheticsBasicAuthDigestType::DIGEST,
139 "username".to_string(),
140 ),
141 )))
142 .method("GET".to_string())
143 .url("https://httpbin.org/status/200".to_string()),
144 SyntheticsAPITestStepSubtype::HTTP,
145 ))),
146 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
147 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
148 SyntheticsAssertionTarget::new(
149 SyntheticsAssertionOperator::IS,
150 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
151 200.0 as f64,
152 ),
153 SyntheticsAssertionType::STATUS_CODE,
154 ),
155 ))],
156 "request is sent".to_string(),
157 SyntheticsTestRequest::new()
158 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
159 Box::new(SyntheticsBasicAuthOauthClient::new(
160 "accessTokenUrl".to_string(),
161 "clientId".to_string(),
162 "clientSecret".to_string(),
163 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
164 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
165 )),
166 ))
167 .method("GET".to_string())
168 .url("https://httpbin.org/status/200".to_string()),
169 SyntheticsAPITestStepSubtype::HTTP,
170 ))),
171 SyntheticsAPIStep::SyntheticsAPITestStep(Box::new(SyntheticsAPITestStep::new(
172 vec![SyntheticsAssertion::SyntheticsAssertionTarget(Box::new(
173 SyntheticsAssertionTarget::new(
174 SyntheticsAssertionOperator::IS,
175 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
176 200.0 as f64,
177 ),
178 SyntheticsAssertionType::STATUS_CODE,
179 ),
180 ))],
181 "request is sent".to_string(),
182 SyntheticsTestRequest::new()
183 .basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthOauthROP(Box::new(
184 SyntheticsBasicAuthOauthROP::new(
185 "accessTokenUrl".to_string(),
186 "password".to_string(),
187 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
188 SyntheticsBasicAuthOauthROPType::OAUTH_ROP,
189 "username".to_string(),
190 ),
191 )))
192 .method("GET".to_string())
193 .url("https://httpbin.org/status/200".to_string()),
194 SyntheticsAPITestStepSubtype::HTTP,
195 ))),
196 ]),
197 vec!["aws:us-east-2".to_string()],
198 "BDD test payload: synthetics_api_test_multi_step_with_every_type_of_basic_auth.json"
199 .to_string(),
200 "Example-Synthetic".to_string(),
201 SyntheticsTestOptions::new().tick_every(60),
202 SyntheticsAPITestType::API,
203 )
204 .subtype(SyntheticsTestDetailsSubType::MULTI);
205 let configuration = datadog::Configuration::new();
206 let api = SyntheticsAPI::with_config(configuration);
207 let resp = api.create_synthetics_api_test(body).await;
208 if let Ok(value) = resp {
209 println!("{:#?}", value);
210 } else {
211 println!("{:#?}", resp.unwrap_err());
212 }
213}
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (lines 173-179)
46async fn main() {
47 let body =
48 SyntheticsAPITest::new(
49 SyntheticsAPITestConfig::new()
50 .assertions(
51 vec![
52 SyntheticsAssertion::SyntheticsAssertionTarget(
53 Box::new(
54 SyntheticsAssertionTarget::new(
55 SyntheticsAssertionOperator::IS,
56 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57 "text/html".to_string(),
58 ),
59 SyntheticsAssertionType::HEADER,
60 ).property("{{ PROPERTY }}".to_string()),
61 ),
62 ),
63 SyntheticsAssertion::SyntheticsAssertionTarget(
64 Box::new(
65 SyntheticsAssertionTarget::new(
66 SyntheticsAssertionOperator::LESS_THAN,
67 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68 2000.0 as f64,
69 ),
70 SyntheticsAssertionType::RESPONSE_TIME,
71 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72 ),
73 ),
74 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75 Box::new(
76 SyntheticsAssertionJSONPathTarget::new(
77 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78 SyntheticsAssertionType::BODY,
79 ).target(
80 SyntheticsAssertionJSONPathTargetTarget::new()
81 .json_path("topKey".to_string())
82 .operator("isNot".to_string())
83 .target_value(
84 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85 "0".to_string(),
86 ),
87 ),
88 ),
89 ),
90 ),
91 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92 Box::new(
93 SyntheticsAssertionJSONPathTarget::new(
94 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95 SyntheticsAssertionType::BODY,
96 ).target(
97 SyntheticsAssertionJSONPathTargetTarget::new()
98 .elements_operator("atLeastOneElementMatches".to_string())
99 .json_path("topKey".to_string())
100 .operator("isNot".to_string())
101 .target_value(
102 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103 "0".to_string(),
104 ),
105 ),
106 ),
107 ),
108 ),
109 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110 Box::new(
111 SyntheticsAssertionJSONSchemaTarget::new(
112 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113 SyntheticsAssertionType::BODY,
114 ).target(
115 SyntheticsAssertionJSONSchemaTargetTarget::new()
116 .json_schema(
117 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118 )
119 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120 ),
121 ),
122 ),
123 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124 Box::new(
125 SyntheticsAssertionXPathTarget::new(
126 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127 SyntheticsAssertionType::BODY,
128 ).target(
129 SyntheticsAssertionXPathTargetTarget::new()
130 .operator("contains".to_string())
131 .target_value(
132 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133 "0".to_string(),
134 ),
135 )
136 .x_path("target-xpath".to_string()),
137 ),
138 ),
139 ),
140 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141 Box::new(
142 SyntheticsAssertionBodyHashTarget::new(
143 SyntheticsAssertionBodyHashOperator::MD5,
144 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145 "a".to_string(),
146 ),
147 SyntheticsAssertionBodyHashType::BODY_HASH,
148 ),
149 ),
150 ),
151 SyntheticsAssertion::SyntheticsAssertionJavascript(
152 Box::new(
153 SyntheticsAssertionJavascript::new(
154 "const hello = 'world';".to_string(),
155 SyntheticsAssertionJavascriptType::JAVASCRIPT,
156 ),
157 ),
158 )
159 ],
160 )
161 .config_variables(
162 vec![
163 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164 .example("content-type".to_string())
165 .pattern("content-type".to_string())
166 ],
167 )
168 .request(
169 SyntheticsTestRequest::new()
170 .basic_auth(
171 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172 Box::new(
173 SyntheticsBasicAuthOauthClient::new(
174 "https://datadog-token.com".to_string(),
175 "client-id".to_string(),
176 "client-secret".to_string(),
177 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179 )
180 .audience("audience".to_string())
181 .resource("resource".to_string())
182 .scope("yoyo".to_string()),
183 ),
184 ),
185 )
186 .certificate(
187 SyntheticsTestRequestCertificate::new()
188 .cert(
189 SyntheticsTestRequestCertificateItem::new()
190 .content("cert-content".to_string())
191 .filename("cert-filename".to_string())
192 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193 )
194 .key(
195 SyntheticsTestRequestCertificateItem::new()
196 .content("key-content".to_string())
197 .filename("key-filename".to_string())
198 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199 ),
200 )
201 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202 .method("GET".to_string())
203 .persist_cookies(true)
204 .proxy(
205 SyntheticsTestRequestProxy::new(
206 "https://datadoghq.com".to_string(),
207 ).headers(BTreeMap::from([])),
208 )
209 .timeout(10.0 as f64)
210 .url("https://datadoghq.com".to_string()),
211 )
212 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213 vec!["aws:us-east-2".to_string()],
214 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215 "Example-Synthetic".to_string(),
216 SyntheticsTestOptions::new()
217 .accept_self_signed(false)
218 .allow_insecure(true)
219 .follow_redirects(true)
220 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221 .min_failure_duration(10)
222 .min_location_failed(1)
223 .monitor_name("Example-Synthetic".to_string())
224 .monitor_priority(5)
225 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226 .tick_every(60),
227 SyntheticsAPITestType::API,
228 )
229 .subtype(SyntheticsTestDetailsSubType::HTTP)
230 .tags(vec!["testing:api".to_string()]);
231 let configuration = datadog::Configuration::new();
232 let api = SyntheticsAPI::with_config(configuration);
233 let resp = api.create_synthetics_api_test(body).await;
234 if let Ok(value) = resp {
235 println!("{:#?}", value);
236 } else {
237 println!("{:#?}", resp.unwrap_err());
238 }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (lines 172-178)
45async fn main() {
46 let body =
47 SyntheticsAPITest::new(
48 SyntheticsAPITestConfig::new()
49 .assertions(
50 vec![
51 SyntheticsAssertion::SyntheticsAssertionTarget(
52 Box::new(
53 SyntheticsAssertionTarget::new(
54 SyntheticsAssertionOperator::IS,
55 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56 "text/html".to_string(),
57 ),
58 SyntheticsAssertionType::HEADER,
59 ).property("{{ PROPERTY }}".to_string()),
60 ),
61 ),
62 SyntheticsAssertion::SyntheticsAssertionTarget(
63 Box::new(
64 SyntheticsAssertionTarget::new(
65 SyntheticsAssertionOperator::LESS_THAN,
66 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67 2000.0 as f64,
68 ),
69 SyntheticsAssertionType::RESPONSE_TIME,
70 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71 ),
72 ),
73 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74 Box::new(
75 SyntheticsAssertionJSONPathTarget::new(
76 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77 SyntheticsAssertionType::BODY,
78 ).target(
79 SyntheticsAssertionJSONPathTargetTarget::new()
80 .json_path("topKey".to_string())
81 .operator("isNot".to_string())
82 .target_value(
83 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84 "0".to_string(),
85 ),
86 ),
87 ),
88 ),
89 ),
90 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91 Box::new(
92 SyntheticsAssertionJSONPathTarget::new(
93 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94 SyntheticsAssertionType::BODY,
95 ).target(
96 SyntheticsAssertionJSONPathTargetTarget::new()
97 .elements_operator("atLeastOneElementMatches".to_string())
98 .json_path("topKey".to_string())
99 .operator("isNot".to_string())
100 .target_value(
101 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102 "0".to_string(),
103 ),
104 ),
105 ),
106 ),
107 ),
108 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109 Box::new(
110 SyntheticsAssertionJSONSchemaTarget::new(
111 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112 SyntheticsAssertionType::BODY,
113 ).target(
114 SyntheticsAssertionJSONSchemaTargetTarget::new()
115 .json_schema(
116 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117 )
118 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119 ),
120 ),
121 ),
122 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123 Box::new(
124 SyntheticsAssertionXPathTarget::new(
125 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126 SyntheticsAssertionType::BODY,
127 ).target(
128 SyntheticsAssertionXPathTargetTarget::new()
129 .operator("contains".to_string())
130 .target_value(
131 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132 "0".to_string(),
133 ),
134 )
135 .x_path("target-xpath".to_string()),
136 ),
137 ),
138 ),
139 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140 Box::new(
141 SyntheticsAssertionBodyHashTarget::new(
142 SyntheticsAssertionBodyHashOperator::MD5,
143 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144 "a".to_string(),
145 ),
146 SyntheticsAssertionBodyHashType::BODY_HASH,
147 ),
148 ),
149 ),
150 SyntheticsAssertion::SyntheticsAssertionJavascript(
151 Box::new(
152 SyntheticsAssertionJavascript::new(
153 "const hello = 'world';".to_string(),
154 SyntheticsAssertionJavascriptType::JAVASCRIPT,
155 ),
156 ),
157 )
158 ],
159 )
160 .config_variables(
161 vec![
162 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163 .example("content-type".to_string())
164 .pattern("content-type".to_string())
165 ],
166 )
167 .request(
168 SyntheticsTestRequest::new()
169 .basic_auth(
170 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171 Box::new(
172 SyntheticsBasicAuthOauthClient::new(
173 "https://datadog-token.com".to_string(),
174 "client-id".to_string(),
175 "client-secret".to_string(),
176 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178 )
179 .audience("audience".to_string())
180 .resource("resource".to_string())
181 .scope("yoyo".to_string()),
182 ),
183 ),
184 )
185 .certificate(
186 SyntheticsTestRequestCertificate::new()
187 .cert(
188 SyntheticsTestRequestCertificateItem::new()
189 .content("cert-content".to_string())
190 .filename("cert-filename".to_string())
191 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192 )
193 .key(
194 SyntheticsTestRequestCertificateItem::new()
195 .content("key-content".to_string())
196 .filename("key-filename".to_string())
197 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198 ),
199 )
200 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201 .method("GET".to_string())
202 .persist_cookies(true)
203 .proxy(
204 SyntheticsTestRequestProxy::new(
205 "https://datadoghq.com".to_string(),
206 ).headers(BTreeMap::from([])),
207 )
208 .timeout(10.0 as f64)
209 .url("https://datadoghq.com".to_string()),
210 )
211 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212 vec!["aws:us-east-2".to_string()],
213 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214 "Example-Synthetic".to_string(),
215 SyntheticsTestOptions::new()
216 .accept_self_signed(false)
217 .allow_insecure(true)
218 .follow_redirects(true)
219 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220 .min_failure_duration(10)
221 .min_location_failed(1)
222 .monitor_name("Example-Synthetic".to_string())
223 .monitor_priority(5)
224 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225 .tick_every(60),
226 SyntheticsAPITestType::API,
227 )
228 .subtype(SyntheticsTestDetailsSubType::HTTP)
229 .tags(vec!["testing:api".to_string()]);
230 let configuration = datadog::Configuration::new();
231 let api = SyntheticsAPI::with_config(configuration);
232 let resp = api.create_synthetics_api_test(body).await;
233 if let Ok(value) = resp {
234 println!("{:#?}", value);
235 } else {
236 println!("{:#?}", resp.unwrap_err());
237 }
238}
Sourcepub fn audience(self, value: String) -> Self
pub fn audience(self, value: String) -> Self
Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 122)
39async fn main() {
40 let body =
41 SyntheticsAPITest::new(
42 SyntheticsAPITestConfig::new()
43 .assertions(
44 vec![
45 SyntheticsAssertion::SyntheticsAssertionTarget(
46 Box::new(
47 SyntheticsAssertionTarget::new(
48 SyntheticsAssertionOperator::IS,
49 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50 "text/html".to_string(),
51 ),
52 SyntheticsAssertionType::HEADER,
53 ).property("{{ PROPERTY }}".to_string()),
54 ),
55 ),
56 SyntheticsAssertion::SyntheticsAssertionTarget(
57 Box::new(
58 SyntheticsAssertionTarget::new(
59 SyntheticsAssertionOperator::LESS_THAN,
60 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61 2000.0 as f64,
62 ),
63 SyntheticsAssertionType::RESPONSE_TIME,
64 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65 ),
66 ),
67 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68 Box::new(
69 SyntheticsAssertionJSONPathTarget::new(
70 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71 SyntheticsAssertionType::BODY,
72 ).target(
73 SyntheticsAssertionJSONPathTargetTarget::new()
74 .json_path("topKey".to_string())
75 .operator("isNot".to_string())
76 .target_value(
77 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78 "0".to_string(),
79 ),
80 ),
81 ),
82 ),
83 ),
84 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85 Box::new(
86 SyntheticsAssertionXPathTarget::new(
87 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88 SyntheticsAssertionType::BODY,
89 ).target(
90 SyntheticsAssertionXPathTargetTarget::new()
91 .operator("contains".to_string())
92 .target_value(
93 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94 "0".to_string(),
95 ),
96 )
97 .x_path("target-xpath".to_string()),
98 ),
99 ),
100 )
101 ],
102 )
103 .config_variables(
104 vec![
105 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106 .example("content-type".to_string())
107 .pattern("content-type".to_string())
108 ],
109 )
110 .request(
111 SyntheticsTestRequest::new()
112 .basic_auth(
113 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114 Box::new(
115 SyntheticsBasicAuthOauthClient::new(
116 "https://datadog-token.com".to_string(),
117 "client-id".to_string(),
118 "client-secret".to_string(),
119 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121 )
122 .audience("audience".to_string())
123 .resource("resource".to_string())
124 .scope("yoyo".to_string()),
125 ),
126 ),
127 )
128 .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129 .certificate(
130 SyntheticsTestRequestCertificate::new()
131 .cert(
132 SyntheticsTestRequestCertificateItem::new()
133 .content("cert-content".to_string())
134 .filename("cert-filename".to_string())
135 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136 )
137 .key(
138 SyntheticsTestRequestCertificateItem::new()
139 .content("key-content".to_string())
140 .filename("key-filename".to_string())
141 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142 ),
143 )
144 .files(
145 vec![
146 SyntheticsTestRequestBodyFile::new()
147 .content("file content".to_string())
148 .name("file name".to_string())
149 .original_file_name("image.png".to_string())
150 .type_("file type".to_string())
151 ],
152 )
153 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154 .method("GET".to_string())
155 .persist_cookies(true)
156 .proxy(
157 SyntheticsTestRequestProxy::new(
158 "https://datadoghq.com".to_string(),
159 ).headers(BTreeMap::from([])),
160 )
161 .timeout(10.0 as f64)
162 .url("https://datadoghq.com".to_string()),
163 ),
164 vec!["aws:us-east-2".to_string()],
165 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166 "Example-Synthetic".to_string(),
167 SyntheticsTestOptions::new()
168 .accept_self_signed(false)
169 .allow_insecure(true)
170 .follow_redirects(true)
171 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172 .min_failure_duration(10)
173 .min_location_failed(1)
174 .monitor_name("Example-Synthetic".to_string())
175 .monitor_priority(5)
176 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177 .tick_every(60),
178 SyntheticsAPITestType::API,
179 )
180 .subtype(SyntheticsTestDetailsSubType::HTTP)
181 .tags(vec!["testing:api".to_string()]);
182 let configuration = datadog::Configuration::new();
183 let api = SyntheticsAPI::with_config(configuration);
184 let resp = api.create_synthetics_api_test(body).await;
185 if let Ok(value) = resp {
186 println!("{:#?}", value);
187 } else {
188 println!("{:#?}", resp.unwrap_err());
189 }
190}
More examples
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 180)
46async fn main() {
47 let body =
48 SyntheticsAPITest::new(
49 SyntheticsAPITestConfig::new()
50 .assertions(
51 vec![
52 SyntheticsAssertion::SyntheticsAssertionTarget(
53 Box::new(
54 SyntheticsAssertionTarget::new(
55 SyntheticsAssertionOperator::IS,
56 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57 "text/html".to_string(),
58 ),
59 SyntheticsAssertionType::HEADER,
60 ).property("{{ PROPERTY }}".to_string()),
61 ),
62 ),
63 SyntheticsAssertion::SyntheticsAssertionTarget(
64 Box::new(
65 SyntheticsAssertionTarget::new(
66 SyntheticsAssertionOperator::LESS_THAN,
67 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68 2000.0 as f64,
69 ),
70 SyntheticsAssertionType::RESPONSE_TIME,
71 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72 ),
73 ),
74 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75 Box::new(
76 SyntheticsAssertionJSONPathTarget::new(
77 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78 SyntheticsAssertionType::BODY,
79 ).target(
80 SyntheticsAssertionJSONPathTargetTarget::new()
81 .json_path("topKey".to_string())
82 .operator("isNot".to_string())
83 .target_value(
84 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85 "0".to_string(),
86 ),
87 ),
88 ),
89 ),
90 ),
91 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92 Box::new(
93 SyntheticsAssertionJSONPathTarget::new(
94 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95 SyntheticsAssertionType::BODY,
96 ).target(
97 SyntheticsAssertionJSONPathTargetTarget::new()
98 .elements_operator("atLeastOneElementMatches".to_string())
99 .json_path("topKey".to_string())
100 .operator("isNot".to_string())
101 .target_value(
102 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103 "0".to_string(),
104 ),
105 ),
106 ),
107 ),
108 ),
109 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110 Box::new(
111 SyntheticsAssertionJSONSchemaTarget::new(
112 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113 SyntheticsAssertionType::BODY,
114 ).target(
115 SyntheticsAssertionJSONSchemaTargetTarget::new()
116 .json_schema(
117 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118 )
119 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120 ),
121 ),
122 ),
123 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124 Box::new(
125 SyntheticsAssertionXPathTarget::new(
126 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127 SyntheticsAssertionType::BODY,
128 ).target(
129 SyntheticsAssertionXPathTargetTarget::new()
130 .operator("contains".to_string())
131 .target_value(
132 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133 "0".to_string(),
134 ),
135 )
136 .x_path("target-xpath".to_string()),
137 ),
138 ),
139 ),
140 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141 Box::new(
142 SyntheticsAssertionBodyHashTarget::new(
143 SyntheticsAssertionBodyHashOperator::MD5,
144 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145 "a".to_string(),
146 ),
147 SyntheticsAssertionBodyHashType::BODY_HASH,
148 ),
149 ),
150 ),
151 SyntheticsAssertion::SyntheticsAssertionJavascript(
152 Box::new(
153 SyntheticsAssertionJavascript::new(
154 "const hello = 'world';".to_string(),
155 SyntheticsAssertionJavascriptType::JAVASCRIPT,
156 ),
157 ),
158 )
159 ],
160 )
161 .config_variables(
162 vec![
163 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164 .example("content-type".to_string())
165 .pattern("content-type".to_string())
166 ],
167 )
168 .request(
169 SyntheticsTestRequest::new()
170 .basic_auth(
171 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172 Box::new(
173 SyntheticsBasicAuthOauthClient::new(
174 "https://datadog-token.com".to_string(),
175 "client-id".to_string(),
176 "client-secret".to_string(),
177 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179 )
180 .audience("audience".to_string())
181 .resource("resource".to_string())
182 .scope("yoyo".to_string()),
183 ),
184 ),
185 )
186 .certificate(
187 SyntheticsTestRequestCertificate::new()
188 .cert(
189 SyntheticsTestRequestCertificateItem::new()
190 .content("cert-content".to_string())
191 .filename("cert-filename".to_string())
192 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193 )
194 .key(
195 SyntheticsTestRequestCertificateItem::new()
196 .content("key-content".to_string())
197 .filename("key-filename".to_string())
198 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199 ),
200 )
201 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202 .method("GET".to_string())
203 .persist_cookies(true)
204 .proxy(
205 SyntheticsTestRequestProxy::new(
206 "https://datadoghq.com".to_string(),
207 ).headers(BTreeMap::from([])),
208 )
209 .timeout(10.0 as f64)
210 .url("https://datadoghq.com".to_string()),
211 )
212 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213 vec!["aws:us-east-2".to_string()],
214 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215 "Example-Synthetic".to_string(),
216 SyntheticsTestOptions::new()
217 .accept_self_signed(false)
218 .allow_insecure(true)
219 .follow_redirects(true)
220 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221 .min_failure_duration(10)
222 .min_location_failed(1)
223 .monitor_name("Example-Synthetic".to_string())
224 .monitor_priority(5)
225 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226 .tick_every(60),
227 SyntheticsAPITestType::API,
228 )
229 .subtype(SyntheticsTestDetailsSubType::HTTP)
230 .tags(vec!["testing:api".to_string()]);
231 let configuration = datadog::Configuration::new();
232 let api = SyntheticsAPI::with_config(configuration);
233 let resp = api.create_synthetics_api_test(body).await;
234 if let Ok(value) = resp {
235 println!("{:#?}", value);
236 } else {
237 println!("{:#?}", resp.unwrap_err());
238 }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 179)
45async fn main() {
46 let body =
47 SyntheticsAPITest::new(
48 SyntheticsAPITestConfig::new()
49 .assertions(
50 vec![
51 SyntheticsAssertion::SyntheticsAssertionTarget(
52 Box::new(
53 SyntheticsAssertionTarget::new(
54 SyntheticsAssertionOperator::IS,
55 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56 "text/html".to_string(),
57 ),
58 SyntheticsAssertionType::HEADER,
59 ).property("{{ PROPERTY }}".to_string()),
60 ),
61 ),
62 SyntheticsAssertion::SyntheticsAssertionTarget(
63 Box::new(
64 SyntheticsAssertionTarget::new(
65 SyntheticsAssertionOperator::LESS_THAN,
66 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67 2000.0 as f64,
68 ),
69 SyntheticsAssertionType::RESPONSE_TIME,
70 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71 ),
72 ),
73 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74 Box::new(
75 SyntheticsAssertionJSONPathTarget::new(
76 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77 SyntheticsAssertionType::BODY,
78 ).target(
79 SyntheticsAssertionJSONPathTargetTarget::new()
80 .json_path("topKey".to_string())
81 .operator("isNot".to_string())
82 .target_value(
83 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84 "0".to_string(),
85 ),
86 ),
87 ),
88 ),
89 ),
90 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91 Box::new(
92 SyntheticsAssertionJSONPathTarget::new(
93 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94 SyntheticsAssertionType::BODY,
95 ).target(
96 SyntheticsAssertionJSONPathTargetTarget::new()
97 .elements_operator("atLeastOneElementMatches".to_string())
98 .json_path("topKey".to_string())
99 .operator("isNot".to_string())
100 .target_value(
101 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102 "0".to_string(),
103 ),
104 ),
105 ),
106 ),
107 ),
108 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109 Box::new(
110 SyntheticsAssertionJSONSchemaTarget::new(
111 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112 SyntheticsAssertionType::BODY,
113 ).target(
114 SyntheticsAssertionJSONSchemaTargetTarget::new()
115 .json_schema(
116 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117 )
118 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119 ),
120 ),
121 ),
122 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123 Box::new(
124 SyntheticsAssertionXPathTarget::new(
125 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126 SyntheticsAssertionType::BODY,
127 ).target(
128 SyntheticsAssertionXPathTargetTarget::new()
129 .operator("contains".to_string())
130 .target_value(
131 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132 "0".to_string(),
133 ),
134 )
135 .x_path("target-xpath".to_string()),
136 ),
137 ),
138 ),
139 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140 Box::new(
141 SyntheticsAssertionBodyHashTarget::new(
142 SyntheticsAssertionBodyHashOperator::MD5,
143 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144 "a".to_string(),
145 ),
146 SyntheticsAssertionBodyHashType::BODY_HASH,
147 ),
148 ),
149 ),
150 SyntheticsAssertion::SyntheticsAssertionJavascript(
151 Box::new(
152 SyntheticsAssertionJavascript::new(
153 "const hello = 'world';".to_string(),
154 SyntheticsAssertionJavascriptType::JAVASCRIPT,
155 ),
156 ),
157 )
158 ],
159 )
160 .config_variables(
161 vec![
162 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163 .example("content-type".to_string())
164 .pattern("content-type".to_string())
165 ],
166 )
167 .request(
168 SyntheticsTestRequest::new()
169 .basic_auth(
170 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171 Box::new(
172 SyntheticsBasicAuthOauthClient::new(
173 "https://datadog-token.com".to_string(),
174 "client-id".to_string(),
175 "client-secret".to_string(),
176 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178 )
179 .audience("audience".to_string())
180 .resource("resource".to_string())
181 .scope("yoyo".to_string()),
182 ),
183 ),
184 )
185 .certificate(
186 SyntheticsTestRequestCertificate::new()
187 .cert(
188 SyntheticsTestRequestCertificateItem::new()
189 .content("cert-content".to_string())
190 .filename("cert-filename".to_string())
191 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192 )
193 .key(
194 SyntheticsTestRequestCertificateItem::new()
195 .content("key-content".to_string())
196 .filename("key-filename".to_string())
197 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198 ),
199 )
200 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201 .method("GET".to_string())
202 .persist_cookies(true)
203 .proxy(
204 SyntheticsTestRequestProxy::new(
205 "https://datadoghq.com".to_string(),
206 ).headers(BTreeMap::from([])),
207 )
208 .timeout(10.0 as f64)
209 .url("https://datadoghq.com".to_string()),
210 )
211 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212 vec!["aws:us-east-2".to_string()],
213 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214 "Example-Synthetic".to_string(),
215 SyntheticsTestOptions::new()
216 .accept_self_signed(false)
217 .allow_insecure(true)
218 .follow_redirects(true)
219 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220 .min_failure_duration(10)
221 .min_location_failed(1)
222 .monitor_name("Example-Synthetic".to_string())
223 .monitor_priority(5)
224 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225 .tick_every(60),
226 SyntheticsAPITestType::API,
227 )
228 .subtype(SyntheticsTestDetailsSubType::HTTP)
229 .tags(vec!["testing:api".to_string()]);
230 let configuration = datadog::Configuration::new();
231 let api = SyntheticsAPI::with_config(configuration);
232 let resp = api.create_synthetics_api_test(body).await;
233 if let Ok(value) = resp {
234 println!("{:#?}", value);
235 } else {
236 println!("{:#?}", resp.unwrap_err());
237 }
238}
Sourcepub fn resource(self, value: String) -> Self
pub fn resource(self, value: String) -> Self
Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 123)
39async fn main() {
40 let body =
41 SyntheticsAPITest::new(
42 SyntheticsAPITestConfig::new()
43 .assertions(
44 vec![
45 SyntheticsAssertion::SyntheticsAssertionTarget(
46 Box::new(
47 SyntheticsAssertionTarget::new(
48 SyntheticsAssertionOperator::IS,
49 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50 "text/html".to_string(),
51 ),
52 SyntheticsAssertionType::HEADER,
53 ).property("{{ PROPERTY }}".to_string()),
54 ),
55 ),
56 SyntheticsAssertion::SyntheticsAssertionTarget(
57 Box::new(
58 SyntheticsAssertionTarget::new(
59 SyntheticsAssertionOperator::LESS_THAN,
60 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61 2000.0 as f64,
62 ),
63 SyntheticsAssertionType::RESPONSE_TIME,
64 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65 ),
66 ),
67 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68 Box::new(
69 SyntheticsAssertionJSONPathTarget::new(
70 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71 SyntheticsAssertionType::BODY,
72 ).target(
73 SyntheticsAssertionJSONPathTargetTarget::new()
74 .json_path("topKey".to_string())
75 .operator("isNot".to_string())
76 .target_value(
77 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78 "0".to_string(),
79 ),
80 ),
81 ),
82 ),
83 ),
84 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85 Box::new(
86 SyntheticsAssertionXPathTarget::new(
87 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88 SyntheticsAssertionType::BODY,
89 ).target(
90 SyntheticsAssertionXPathTargetTarget::new()
91 .operator("contains".to_string())
92 .target_value(
93 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94 "0".to_string(),
95 ),
96 )
97 .x_path("target-xpath".to_string()),
98 ),
99 ),
100 )
101 ],
102 )
103 .config_variables(
104 vec![
105 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106 .example("content-type".to_string())
107 .pattern("content-type".to_string())
108 ],
109 )
110 .request(
111 SyntheticsTestRequest::new()
112 .basic_auth(
113 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114 Box::new(
115 SyntheticsBasicAuthOauthClient::new(
116 "https://datadog-token.com".to_string(),
117 "client-id".to_string(),
118 "client-secret".to_string(),
119 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121 )
122 .audience("audience".to_string())
123 .resource("resource".to_string())
124 .scope("yoyo".to_string()),
125 ),
126 ),
127 )
128 .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129 .certificate(
130 SyntheticsTestRequestCertificate::new()
131 .cert(
132 SyntheticsTestRequestCertificateItem::new()
133 .content("cert-content".to_string())
134 .filename("cert-filename".to_string())
135 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136 )
137 .key(
138 SyntheticsTestRequestCertificateItem::new()
139 .content("key-content".to_string())
140 .filename("key-filename".to_string())
141 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142 ),
143 )
144 .files(
145 vec![
146 SyntheticsTestRequestBodyFile::new()
147 .content("file content".to_string())
148 .name("file name".to_string())
149 .original_file_name("image.png".to_string())
150 .type_("file type".to_string())
151 ],
152 )
153 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154 .method("GET".to_string())
155 .persist_cookies(true)
156 .proxy(
157 SyntheticsTestRequestProxy::new(
158 "https://datadoghq.com".to_string(),
159 ).headers(BTreeMap::from([])),
160 )
161 .timeout(10.0 as f64)
162 .url("https://datadoghq.com".to_string()),
163 ),
164 vec!["aws:us-east-2".to_string()],
165 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166 "Example-Synthetic".to_string(),
167 SyntheticsTestOptions::new()
168 .accept_self_signed(false)
169 .allow_insecure(true)
170 .follow_redirects(true)
171 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172 .min_failure_duration(10)
173 .min_location_failed(1)
174 .monitor_name("Example-Synthetic".to_string())
175 .monitor_priority(5)
176 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177 .tick_every(60),
178 SyntheticsAPITestType::API,
179 )
180 .subtype(SyntheticsTestDetailsSubType::HTTP)
181 .tags(vec!["testing:api".to_string()]);
182 let configuration = datadog::Configuration::new();
183 let api = SyntheticsAPI::with_config(configuration);
184 let resp = api.create_synthetics_api_test(body).await;
185 if let Ok(value) = resp {
186 println!("{:#?}", value);
187 } else {
188 println!("{:#?}", resp.unwrap_err());
189 }
190}
More examples
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 181)
46async fn main() {
47 let body =
48 SyntheticsAPITest::new(
49 SyntheticsAPITestConfig::new()
50 .assertions(
51 vec![
52 SyntheticsAssertion::SyntheticsAssertionTarget(
53 Box::new(
54 SyntheticsAssertionTarget::new(
55 SyntheticsAssertionOperator::IS,
56 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57 "text/html".to_string(),
58 ),
59 SyntheticsAssertionType::HEADER,
60 ).property("{{ PROPERTY }}".to_string()),
61 ),
62 ),
63 SyntheticsAssertion::SyntheticsAssertionTarget(
64 Box::new(
65 SyntheticsAssertionTarget::new(
66 SyntheticsAssertionOperator::LESS_THAN,
67 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68 2000.0 as f64,
69 ),
70 SyntheticsAssertionType::RESPONSE_TIME,
71 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72 ),
73 ),
74 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75 Box::new(
76 SyntheticsAssertionJSONPathTarget::new(
77 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78 SyntheticsAssertionType::BODY,
79 ).target(
80 SyntheticsAssertionJSONPathTargetTarget::new()
81 .json_path("topKey".to_string())
82 .operator("isNot".to_string())
83 .target_value(
84 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85 "0".to_string(),
86 ),
87 ),
88 ),
89 ),
90 ),
91 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92 Box::new(
93 SyntheticsAssertionJSONPathTarget::new(
94 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95 SyntheticsAssertionType::BODY,
96 ).target(
97 SyntheticsAssertionJSONPathTargetTarget::new()
98 .elements_operator("atLeastOneElementMatches".to_string())
99 .json_path("topKey".to_string())
100 .operator("isNot".to_string())
101 .target_value(
102 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103 "0".to_string(),
104 ),
105 ),
106 ),
107 ),
108 ),
109 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110 Box::new(
111 SyntheticsAssertionJSONSchemaTarget::new(
112 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113 SyntheticsAssertionType::BODY,
114 ).target(
115 SyntheticsAssertionJSONSchemaTargetTarget::new()
116 .json_schema(
117 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118 )
119 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120 ),
121 ),
122 ),
123 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124 Box::new(
125 SyntheticsAssertionXPathTarget::new(
126 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127 SyntheticsAssertionType::BODY,
128 ).target(
129 SyntheticsAssertionXPathTargetTarget::new()
130 .operator("contains".to_string())
131 .target_value(
132 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133 "0".to_string(),
134 ),
135 )
136 .x_path("target-xpath".to_string()),
137 ),
138 ),
139 ),
140 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141 Box::new(
142 SyntheticsAssertionBodyHashTarget::new(
143 SyntheticsAssertionBodyHashOperator::MD5,
144 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145 "a".to_string(),
146 ),
147 SyntheticsAssertionBodyHashType::BODY_HASH,
148 ),
149 ),
150 ),
151 SyntheticsAssertion::SyntheticsAssertionJavascript(
152 Box::new(
153 SyntheticsAssertionJavascript::new(
154 "const hello = 'world';".to_string(),
155 SyntheticsAssertionJavascriptType::JAVASCRIPT,
156 ),
157 ),
158 )
159 ],
160 )
161 .config_variables(
162 vec![
163 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164 .example("content-type".to_string())
165 .pattern("content-type".to_string())
166 ],
167 )
168 .request(
169 SyntheticsTestRequest::new()
170 .basic_auth(
171 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172 Box::new(
173 SyntheticsBasicAuthOauthClient::new(
174 "https://datadog-token.com".to_string(),
175 "client-id".to_string(),
176 "client-secret".to_string(),
177 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179 )
180 .audience("audience".to_string())
181 .resource("resource".to_string())
182 .scope("yoyo".to_string()),
183 ),
184 ),
185 )
186 .certificate(
187 SyntheticsTestRequestCertificate::new()
188 .cert(
189 SyntheticsTestRequestCertificateItem::new()
190 .content("cert-content".to_string())
191 .filename("cert-filename".to_string())
192 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193 )
194 .key(
195 SyntheticsTestRequestCertificateItem::new()
196 .content("key-content".to_string())
197 .filename("key-filename".to_string())
198 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199 ),
200 )
201 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202 .method("GET".to_string())
203 .persist_cookies(true)
204 .proxy(
205 SyntheticsTestRequestProxy::new(
206 "https://datadoghq.com".to_string(),
207 ).headers(BTreeMap::from([])),
208 )
209 .timeout(10.0 as f64)
210 .url("https://datadoghq.com".to_string()),
211 )
212 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213 vec!["aws:us-east-2".to_string()],
214 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215 "Example-Synthetic".to_string(),
216 SyntheticsTestOptions::new()
217 .accept_self_signed(false)
218 .allow_insecure(true)
219 .follow_redirects(true)
220 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221 .min_failure_duration(10)
222 .min_location_failed(1)
223 .monitor_name("Example-Synthetic".to_string())
224 .monitor_priority(5)
225 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226 .tick_every(60),
227 SyntheticsAPITestType::API,
228 )
229 .subtype(SyntheticsTestDetailsSubType::HTTP)
230 .tags(vec!["testing:api".to_string()]);
231 let configuration = datadog::Configuration::new();
232 let api = SyntheticsAPI::with_config(configuration);
233 let resp = api.create_synthetics_api_test(body).await;
234 if let Ok(value) = resp {
235 println!("{:#?}", value);
236 } else {
237 println!("{:#?}", resp.unwrap_err());
238 }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 180)
45async fn main() {
46 let body =
47 SyntheticsAPITest::new(
48 SyntheticsAPITestConfig::new()
49 .assertions(
50 vec![
51 SyntheticsAssertion::SyntheticsAssertionTarget(
52 Box::new(
53 SyntheticsAssertionTarget::new(
54 SyntheticsAssertionOperator::IS,
55 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56 "text/html".to_string(),
57 ),
58 SyntheticsAssertionType::HEADER,
59 ).property("{{ PROPERTY }}".to_string()),
60 ),
61 ),
62 SyntheticsAssertion::SyntheticsAssertionTarget(
63 Box::new(
64 SyntheticsAssertionTarget::new(
65 SyntheticsAssertionOperator::LESS_THAN,
66 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67 2000.0 as f64,
68 ),
69 SyntheticsAssertionType::RESPONSE_TIME,
70 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71 ),
72 ),
73 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74 Box::new(
75 SyntheticsAssertionJSONPathTarget::new(
76 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77 SyntheticsAssertionType::BODY,
78 ).target(
79 SyntheticsAssertionJSONPathTargetTarget::new()
80 .json_path("topKey".to_string())
81 .operator("isNot".to_string())
82 .target_value(
83 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84 "0".to_string(),
85 ),
86 ),
87 ),
88 ),
89 ),
90 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91 Box::new(
92 SyntheticsAssertionJSONPathTarget::new(
93 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94 SyntheticsAssertionType::BODY,
95 ).target(
96 SyntheticsAssertionJSONPathTargetTarget::new()
97 .elements_operator("atLeastOneElementMatches".to_string())
98 .json_path("topKey".to_string())
99 .operator("isNot".to_string())
100 .target_value(
101 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102 "0".to_string(),
103 ),
104 ),
105 ),
106 ),
107 ),
108 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109 Box::new(
110 SyntheticsAssertionJSONSchemaTarget::new(
111 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112 SyntheticsAssertionType::BODY,
113 ).target(
114 SyntheticsAssertionJSONSchemaTargetTarget::new()
115 .json_schema(
116 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117 )
118 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119 ),
120 ),
121 ),
122 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123 Box::new(
124 SyntheticsAssertionXPathTarget::new(
125 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126 SyntheticsAssertionType::BODY,
127 ).target(
128 SyntheticsAssertionXPathTargetTarget::new()
129 .operator("contains".to_string())
130 .target_value(
131 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132 "0".to_string(),
133 ),
134 )
135 .x_path("target-xpath".to_string()),
136 ),
137 ),
138 ),
139 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140 Box::new(
141 SyntheticsAssertionBodyHashTarget::new(
142 SyntheticsAssertionBodyHashOperator::MD5,
143 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144 "a".to_string(),
145 ),
146 SyntheticsAssertionBodyHashType::BODY_HASH,
147 ),
148 ),
149 ),
150 SyntheticsAssertion::SyntheticsAssertionJavascript(
151 Box::new(
152 SyntheticsAssertionJavascript::new(
153 "const hello = 'world';".to_string(),
154 SyntheticsAssertionJavascriptType::JAVASCRIPT,
155 ),
156 ),
157 )
158 ],
159 )
160 .config_variables(
161 vec![
162 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163 .example("content-type".to_string())
164 .pattern("content-type".to_string())
165 ],
166 )
167 .request(
168 SyntheticsTestRequest::new()
169 .basic_auth(
170 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171 Box::new(
172 SyntheticsBasicAuthOauthClient::new(
173 "https://datadog-token.com".to_string(),
174 "client-id".to_string(),
175 "client-secret".to_string(),
176 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178 )
179 .audience("audience".to_string())
180 .resource("resource".to_string())
181 .scope("yoyo".to_string()),
182 ),
183 ),
184 )
185 .certificate(
186 SyntheticsTestRequestCertificate::new()
187 .cert(
188 SyntheticsTestRequestCertificateItem::new()
189 .content("cert-content".to_string())
190 .filename("cert-filename".to_string())
191 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192 )
193 .key(
194 SyntheticsTestRequestCertificateItem::new()
195 .content("key-content".to_string())
196 .filename("key-filename".to_string())
197 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198 ),
199 )
200 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201 .method("GET".to_string())
202 .persist_cookies(true)
203 .proxy(
204 SyntheticsTestRequestProxy::new(
205 "https://datadoghq.com".to_string(),
206 ).headers(BTreeMap::from([])),
207 )
208 .timeout(10.0 as f64)
209 .url("https://datadoghq.com".to_string()),
210 )
211 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212 vec!["aws:us-east-2".to_string()],
213 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214 "Example-Synthetic".to_string(),
215 SyntheticsTestOptions::new()
216 .accept_self_signed(false)
217 .allow_insecure(true)
218 .follow_redirects(true)
219 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220 .min_failure_duration(10)
221 .min_location_failed(1)
222 .monitor_name("Example-Synthetic".to_string())
223 .monitor_priority(5)
224 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225 .tick_every(60),
226 SyntheticsAPITestType::API,
227 )
228 .subtype(SyntheticsTestDetailsSubType::HTTP)
229 .tags(vec!["testing:api".to_string()]);
230 let configuration = datadog::Configuration::new();
231 let api = SyntheticsAPI::with_config(configuration);
232 let resp = api.create_synthetics_api_test(body).await;
233 if let Ok(value) = resp {
234 println!("{:#?}", value);
235 } else {
236 println!("{:#?}", resp.unwrap_err());
237 }
238}
Sourcepub fn scope(self, value: String) -> Self
pub fn scope(self, value: String) -> Self
Examples found in repository?
examples/v1_synthetics_CreateSyntheticsAPITest_1241981394.rs (line 124)
39async fn main() {
40 let body =
41 SyntheticsAPITest::new(
42 SyntheticsAPITestConfig::new()
43 .assertions(
44 vec![
45 SyntheticsAssertion::SyntheticsAssertionTarget(
46 Box::new(
47 SyntheticsAssertionTarget::new(
48 SyntheticsAssertionOperator::IS,
49 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
50 "text/html".to_string(),
51 ),
52 SyntheticsAssertionType::HEADER,
53 ).property("{{ PROPERTY }}".to_string()),
54 ),
55 ),
56 SyntheticsAssertion::SyntheticsAssertionTarget(
57 Box::new(
58 SyntheticsAssertionTarget::new(
59 SyntheticsAssertionOperator::LESS_THAN,
60 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
61 2000.0 as f64,
62 ),
63 SyntheticsAssertionType::RESPONSE_TIME,
64 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
65 ),
66 ),
67 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
68 Box::new(
69 SyntheticsAssertionJSONPathTarget::new(
70 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
71 SyntheticsAssertionType::BODY,
72 ).target(
73 SyntheticsAssertionJSONPathTargetTarget::new()
74 .json_path("topKey".to_string())
75 .operator("isNot".to_string())
76 .target_value(
77 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
78 "0".to_string(),
79 ),
80 ),
81 ),
82 ),
83 ),
84 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
85 Box::new(
86 SyntheticsAssertionXPathTarget::new(
87 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
88 SyntheticsAssertionType::BODY,
89 ).target(
90 SyntheticsAssertionXPathTargetTarget::new()
91 .operator("contains".to_string())
92 .target_value(
93 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
94 "0".to_string(),
95 ),
96 )
97 .x_path("target-xpath".to_string()),
98 ),
99 ),
100 )
101 ],
102 )
103 .config_variables(
104 vec![
105 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
106 .example("content-type".to_string())
107 .pattern("content-type".to_string())
108 ],
109 )
110 .request(
111 SyntheticsTestRequest::new()
112 .basic_auth(
113 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
114 Box::new(
115 SyntheticsBasicAuthOauthClient::new(
116 "https://datadog-token.com".to_string(),
117 "client-id".to_string(),
118 "client-secret".to_string(),
119 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
120 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
121 )
122 .audience("audience".to_string())
123 .resource("resource".to_string())
124 .scope("yoyo".to_string()),
125 ),
126 ),
127 )
128 .body_type(SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM)
129 .certificate(
130 SyntheticsTestRequestCertificate::new()
131 .cert(
132 SyntheticsTestRequestCertificateItem::new()
133 .content("cert-content".to_string())
134 .filename("cert-filename".to_string())
135 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
136 )
137 .key(
138 SyntheticsTestRequestCertificateItem::new()
139 .content("key-content".to_string())
140 .filename("key-filename".to_string())
141 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
142 ),
143 )
144 .files(
145 vec![
146 SyntheticsTestRequestBodyFile::new()
147 .content("file content".to_string())
148 .name("file name".to_string())
149 .original_file_name("image.png".to_string())
150 .type_("file type".to_string())
151 ],
152 )
153 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
154 .method("GET".to_string())
155 .persist_cookies(true)
156 .proxy(
157 SyntheticsTestRequestProxy::new(
158 "https://datadoghq.com".to_string(),
159 ).headers(BTreeMap::from([])),
160 )
161 .timeout(10.0 as f64)
162 .url("https://datadoghq.com".to_string()),
163 ),
164 vec!["aws:us-east-2".to_string()],
165 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
166 "Example-Synthetic".to_string(),
167 SyntheticsTestOptions::new()
168 .accept_self_signed(false)
169 .allow_insecure(true)
170 .follow_redirects(true)
171 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
172 .min_failure_duration(10)
173 .min_location_failed(1)
174 .monitor_name("Example-Synthetic".to_string())
175 .monitor_priority(5)
176 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
177 .tick_every(60),
178 SyntheticsAPITestType::API,
179 )
180 .subtype(SyntheticsTestDetailsSubType::HTTP)
181 .tags(vec!["testing:api".to_string()]);
182 let configuration = datadog::Configuration::new();
183 let api = SyntheticsAPI::with_config(configuration);
184 let resp = api.create_synthetics_api_test(body).await;
185 if let Ok(value) = resp {
186 println!("{:#?}", value);
187 } else {
188 println!("{:#?}", resp.unwrap_err());
189 }
190}
More examples
examples/v1_synthetics_CreateSyntheticsAPITest_1487281163.rs (line 182)
46async fn main() {
47 let body =
48 SyntheticsAPITest::new(
49 SyntheticsAPITestConfig::new()
50 .assertions(
51 vec![
52 SyntheticsAssertion::SyntheticsAssertionTarget(
53 Box::new(
54 SyntheticsAssertionTarget::new(
55 SyntheticsAssertionOperator::IS,
56 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
57 "text/html".to_string(),
58 ),
59 SyntheticsAssertionType::HEADER,
60 ).property("{{ PROPERTY }}".to_string()),
61 ),
62 ),
63 SyntheticsAssertion::SyntheticsAssertionTarget(
64 Box::new(
65 SyntheticsAssertionTarget::new(
66 SyntheticsAssertionOperator::LESS_THAN,
67 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
68 2000.0 as f64,
69 ),
70 SyntheticsAssertionType::RESPONSE_TIME,
71 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
72 ),
73 ),
74 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
75 Box::new(
76 SyntheticsAssertionJSONPathTarget::new(
77 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
78 SyntheticsAssertionType::BODY,
79 ).target(
80 SyntheticsAssertionJSONPathTargetTarget::new()
81 .json_path("topKey".to_string())
82 .operator("isNot".to_string())
83 .target_value(
84 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
85 "0".to_string(),
86 ),
87 ),
88 ),
89 ),
90 ),
91 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
92 Box::new(
93 SyntheticsAssertionJSONPathTarget::new(
94 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
95 SyntheticsAssertionType::BODY,
96 ).target(
97 SyntheticsAssertionJSONPathTargetTarget::new()
98 .elements_operator("atLeastOneElementMatches".to_string())
99 .json_path("topKey".to_string())
100 .operator("isNot".to_string())
101 .target_value(
102 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
103 "0".to_string(),
104 ),
105 ),
106 ),
107 ),
108 ),
109 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
110 Box::new(
111 SyntheticsAssertionJSONSchemaTarget::new(
112 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
113 SyntheticsAssertionType::BODY,
114 ).target(
115 SyntheticsAssertionJSONSchemaTargetTarget::new()
116 .json_schema(
117 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
118 )
119 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
120 ),
121 ),
122 ),
123 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
124 Box::new(
125 SyntheticsAssertionXPathTarget::new(
126 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
127 SyntheticsAssertionType::BODY,
128 ).target(
129 SyntheticsAssertionXPathTargetTarget::new()
130 .operator("contains".to_string())
131 .target_value(
132 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
133 "0".to_string(),
134 ),
135 )
136 .x_path("target-xpath".to_string()),
137 ),
138 ),
139 ),
140 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
141 Box::new(
142 SyntheticsAssertionBodyHashTarget::new(
143 SyntheticsAssertionBodyHashOperator::MD5,
144 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
145 "a".to_string(),
146 ),
147 SyntheticsAssertionBodyHashType::BODY_HASH,
148 ),
149 ),
150 ),
151 SyntheticsAssertion::SyntheticsAssertionJavascript(
152 Box::new(
153 SyntheticsAssertionJavascript::new(
154 "const hello = 'world';".to_string(),
155 SyntheticsAssertionJavascriptType::JAVASCRIPT,
156 ),
157 ),
158 )
159 ],
160 )
161 .config_variables(
162 vec![
163 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
164 .example("content-type".to_string())
165 .pattern("content-type".to_string())
166 ],
167 )
168 .request(
169 SyntheticsTestRequest::new()
170 .basic_auth(
171 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
172 Box::new(
173 SyntheticsBasicAuthOauthClient::new(
174 "https://datadog-token.com".to_string(),
175 "client-id".to_string(),
176 "client-secret".to_string(),
177 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
178 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
179 )
180 .audience("audience".to_string())
181 .resource("resource".to_string())
182 .scope("yoyo".to_string()),
183 ),
184 ),
185 )
186 .certificate(
187 SyntheticsTestRequestCertificate::new()
188 .cert(
189 SyntheticsTestRequestCertificateItem::new()
190 .content("cert-content".to_string())
191 .filename("cert-filename".to_string())
192 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
193 )
194 .key(
195 SyntheticsTestRequestCertificateItem::new()
196 .content("key-content".to_string())
197 .filename("key-filename".to_string())
198 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
199 ),
200 )
201 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
202 .method("GET".to_string())
203 .persist_cookies(true)
204 .proxy(
205 SyntheticsTestRequestProxy::new(
206 "https://datadoghq.com".to_string(),
207 ).headers(BTreeMap::from([])),
208 )
209 .timeout(10.0 as f64)
210 .url("https://datadoghq.com".to_string()),
211 )
212 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
213 vec!["aws:us-east-2".to_string()],
214 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
215 "Example-Synthetic".to_string(),
216 SyntheticsTestOptions::new()
217 .accept_self_signed(false)
218 .allow_insecure(true)
219 .follow_redirects(true)
220 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
221 .min_failure_duration(10)
222 .min_location_failed(1)
223 .monitor_name("Example-Synthetic".to_string())
224 .monitor_priority(5)
225 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
226 .tick_every(60),
227 SyntheticsAPITestType::API,
228 )
229 .subtype(SyntheticsTestDetailsSubType::HTTP)
230 .tags(vec!["testing:api".to_string()]);
231 let configuration = datadog::Configuration::new();
232 let api = SyntheticsAPI::with_config(configuration);
233 let resp = api.create_synthetics_api_test(body).await;
234 if let Ok(value) = resp {
235 println!("{:#?}", value);
236 } else {
237 println!("{:#?}", resp.unwrap_err());
238 }
239}
examples/v1_synthetics_CreateSyntheticsAPITest_1987645492.rs (line 181)
45async fn main() {
46 let body =
47 SyntheticsAPITest::new(
48 SyntheticsAPITestConfig::new()
49 .assertions(
50 vec![
51 SyntheticsAssertion::SyntheticsAssertionTarget(
52 Box::new(
53 SyntheticsAssertionTarget::new(
54 SyntheticsAssertionOperator::IS,
55 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
56 "text/html".to_string(),
57 ),
58 SyntheticsAssertionType::HEADER,
59 ).property("{{ PROPERTY }}".to_string()),
60 ),
61 ),
62 SyntheticsAssertion::SyntheticsAssertionTarget(
63 Box::new(
64 SyntheticsAssertionTarget::new(
65 SyntheticsAssertionOperator::LESS_THAN,
66 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueNumber(
67 2000.0 as f64,
68 ),
69 SyntheticsAssertionType::RESPONSE_TIME,
70 ).timings_scope(SyntheticsAssertionTimingsScope::WITHOUT_DNS),
71 ),
72 ),
73 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
74 Box::new(
75 SyntheticsAssertionJSONPathTarget::new(
76 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
77 SyntheticsAssertionType::BODY,
78 ).target(
79 SyntheticsAssertionJSONPathTargetTarget::new()
80 .json_path("topKey".to_string())
81 .operator("isNot".to_string())
82 .target_value(
83 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
84 "0".to_string(),
85 ),
86 ),
87 ),
88 ),
89 ),
90 SyntheticsAssertion::SyntheticsAssertionJSONPathTarget(
91 Box::new(
92 SyntheticsAssertionJSONPathTarget::new(
93 SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
94 SyntheticsAssertionType::BODY,
95 ).target(
96 SyntheticsAssertionJSONPathTargetTarget::new()
97 .elements_operator("atLeastOneElementMatches".to_string())
98 .json_path("topKey".to_string())
99 .operator("isNot".to_string())
100 .target_value(
101 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
102 "0".to_string(),
103 ),
104 ),
105 ),
106 ),
107 ),
108 SyntheticsAssertion::SyntheticsAssertionJSONSchemaTarget(
109 Box::new(
110 SyntheticsAssertionJSONSchemaTarget::new(
111 SyntheticsAssertionJSONSchemaOperator::VALIDATES_JSON_SCHEMA,
112 SyntheticsAssertionType::BODY,
113 ).target(
114 SyntheticsAssertionJSONSchemaTargetTarget::new()
115 .json_schema(
116 r#"{"type": "object", "properties":{"slideshow":{"type":"object"}}}"#.to_string(),
117 )
118 .meta_schema(SyntheticsAssertionJSONSchemaMetaSchema::DRAFT_07),
119 ),
120 ),
121 ),
122 SyntheticsAssertion::SyntheticsAssertionXPathTarget(
123 Box::new(
124 SyntheticsAssertionXPathTarget::new(
125 SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
126 SyntheticsAssertionType::BODY,
127 ).target(
128 SyntheticsAssertionXPathTargetTarget::new()
129 .operator("contains".to_string())
130 .target_value(
131 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
132 "0".to_string(),
133 ),
134 )
135 .x_path("target-xpath".to_string()),
136 ),
137 ),
138 ),
139 SyntheticsAssertion::SyntheticsAssertionBodyHashTarget(
140 Box::new(
141 SyntheticsAssertionBodyHashTarget::new(
142 SyntheticsAssertionBodyHashOperator::MD5,
143 SyntheticsAssertionTargetValue::SyntheticsAssertionTargetValueString(
144 "a".to_string(),
145 ),
146 SyntheticsAssertionBodyHashType::BODY_HASH,
147 ),
148 ),
149 ),
150 SyntheticsAssertion::SyntheticsAssertionJavascript(
151 Box::new(
152 SyntheticsAssertionJavascript::new(
153 "const hello = 'world';".to_string(),
154 SyntheticsAssertionJavascriptType::JAVASCRIPT,
155 ),
156 ),
157 )
158 ],
159 )
160 .config_variables(
161 vec![
162 SyntheticsConfigVariable::new("PROPERTY".to_string(), SyntheticsConfigVariableType::TEXT)
163 .example("content-type".to_string())
164 .pattern("content-type".to_string())
165 ],
166 )
167 .request(
168 SyntheticsTestRequest::new()
169 .basic_auth(
170 SyntheticsBasicAuth::SyntheticsBasicAuthOauthClient(
171 Box::new(
172 SyntheticsBasicAuthOauthClient::new(
173 "https://datadog-token.com".to_string(),
174 "client-id".to_string(),
175 "client-secret".to_string(),
176 SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
177 SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
178 )
179 .audience("audience".to_string())
180 .resource("resource".to_string())
181 .scope("yoyo".to_string()),
182 ),
183 ),
184 )
185 .certificate(
186 SyntheticsTestRequestCertificate::new()
187 .cert(
188 SyntheticsTestRequestCertificateItem::new()
189 .content("cert-content".to_string())
190 .filename("cert-filename".to_string())
191 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
192 )
193 .key(
194 SyntheticsTestRequestCertificateItem::new()
195 .content("key-content".to_string())
196 .filename("key-filename".to_string())
197 .updated_at("2020-10-16T09:23:24.857Z".to_string()),
198 ),
199 )
200 .headers(BTreeMap::from([("unique".to_string(), "examplesynthetic".to_string())]))
201 .method("GET".to_string())
202 .persist_cookies(true)
203 .proxy(
204 SyntheticsTestRequestProxy::new(
205 "https://datadoghq.com".to_string(),
206 ).headers(BTreeMap::from([])),
207 )
208 .timeout(10.0 as f64)
209 .url("https://datadoghq.com".to_string()),
210 )
211 .variables_from_script(r#"dd.variable.set("FOO", "foo")"#.to_string()),
212 vec!["aws:us-east-2".to_string()],
213 "BDD test payload: synthetics_api_http_test_payload.json".to_string(),
214 "Example-Synthetic".to_string(),
215 SyntheticsTestOptions::new()
216 .accept_self_signed(false)
217 .allow_insecure(true)
218 .follow_redirects(true)
219 .http_version(SyntheticsTestOptionsHTTPVersion::HTTP2)
220 .min_failure_duration(10)
221 .min_location_failed(1)
222 .monitor_name("Example-Synthetic".to_string())
223 .monitor_priority(5)
224 .retry(SyntheticsTestOptionsRetry::new().count(3).interval(10.0 as f64))
225 .tick_every(60),
226 SyntheticsAPITestType::API,
227 )
228 .subtype(SyntheticsTestDetailsSubType::HTTP)
229 .tags(vec!["testing:api".to_string()]);
230 let configuration = datadog::Configuration::new();
231 let api = SyntheticsAPI::with_config(configuration);
232 let resp = api.create_synthetics_api_test(body).await;
233 if let Ok(value) = resp {
234 println!("{:#?}", value);
235 } else {
236 println!("{:#?}", resp.unwrap_err());
237 }
238}
pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self
Trait Implementations§
Source§impl Clone for SyntheticsBasicAuthOauthClient
impl Clone for SyntheticsBasicAuthOauthClient
Source§fn clone(&self) -> SyntheticsBasicAuthOauthClient
fn clone(&self) -> SyntheticsBasicAuthOauthClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'de> Deserialize<'de> for SyntheticsBasicAuthOauthClient
impl<'de> Deserialize<'de> for SyntheticsBasicAuthOauthClient
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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 SyntheticsBasicAuthOauthClient
impl PartialEq for SyntheticsBasicAuthOauthClient
Source§fn eq(&self, other: &SyntheticsBasicAuthOauthClient) -> bool
fn eq(&self, other: &SyntheticsBasicAuthOauthClient) -> bool
Tests for
self
and other
values to be equal, and is used by ==
.impl StructuralPartialEq for SyntheticsBasicAuthOauthClient
Auto Trait Implementations§
impl Freeze for SyntheticsBasicAuthOauthClient
impl RefUnwindSafe for SyntheticsBasicAuthOauthClient
impl Send for SyntheticsBasicAuthOauthClient
impl Sync for SyntheticsBasicAuthOauthClient
impl Unpin for SyntheticsBasicAuthOauthClient
impl UnwindSafe for SyntheticsBasicAuthOauthClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more