Skip to content

Commit 5dff910

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support variablesFromScript in Synthetics API test (#1945)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 6166914 commit 5dff910

16 files changed

+88
-60
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-04-15 13:32:56.776195",
8-
"spec_repo_commit": "5c7e123b"
7+
"regenerated": "2024-04-17 15:28:03.856507",
8+
"spec_repo_commit": "4bea6a2f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-04-15 13:32:56.793599",
13-
"spec_repo_commit": "5c7e123b"
12+
"regenerated": "2024-04-17 15:28:03.873583",
13+
"spec_repo_commit": "4bea6a2f"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13446,6 +13446,10 @@ components:
1344613446
items:
1344713447
$ref: '#/components/schemas/SyntheticsAPIStep'
1344813448
type: array
13449+
variablesFromScript:
13450+
description: Variables defined from JavaScript code.
13451+
example: dd.variable.set("FOO", "foo")
13452+
type: string
1344913453
type: object
1345013454
SyntheticsAPITestResultData:
1345113455
description: Object containing results for your Synthetic API test.

examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
type=SyntheticsConfigVariableType.TEXT,
7979
),
8080
],
81+
variables_from_script='dd.variable.set("FOO", "foo")',
8182
request=SyntheticsTestRequest(
8283
certificate=SyntheticsTestRequestCertificate(
8384
cert=SyntheticsTestRequestCertificateItem(

src/datadog_api_client/v1/model/synthetics_api_test_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ def openapi_types(_):
3636
"config_variables": ([SyntheticsConfigVariable],),
3737
"request": (SyntheticsTestRequest,),
3838
"steps": ([SyntheticsAPIStep],),
39+
"variables_from_script": (str,),
3940
}
4041

4142
attribute_map = {
4243
"assertions": "assertions",
4344
"config_variables": "configVariables",
4445
"request": "request",
4546
"steps": "steps",
47+
"variables_from_script": "variablesFromScript",
4648
}
4749

4850
def __init__(
@@ -61,6 +63,7 @@ def __init__(
6163
config_variables: Union[List[SyntheticsConfigVariable], UnsetType] = unset,
6264
request: Union[SyntheticsTestRequest, UnsetType] = unset,
6365
steps: Union[List[SyntheticsAPIStep], UnsetType] = unset,
66+
variables_from_script: Union[str, UnsetType] = unset,
6467
**kwargs,
6568
):
6669
"""
@@ -77,6 +80,9 @@ def __init__(
7780
7881
:param steps: When the test subtype is ``multi`` , the steps of the test.
7982
:type steps: [SyntheticsAPIStep], optional
83+
84+
:param variables_from_script: Variables defined from JavaScript code.
85+
:type variables_from_script: str, optional
8086
"""
8187
if assertions is not unset:
8288
kwargs["assertions"] = assertions
@@ -86,4 +92,6 @@ def __init__(
8692
kwargs["request"] = request
8793
if steps is not unset:
8894
kwargs["steps"] = steps
95+
if variables_from_script is not unset:
96+
kwargs["variables_from_script"] = variables_from_script
8997
super().__init__(kwargs)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-01-26T10:20:40.621Z
1+
2024-04-17T12:11:41.063Z

tests/v1/cassettes/test_scenarios/test_create_an_api_http_test_returns_ok_returns_the_created_test_details_response.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interactions:
22
- request:
3-
body: '{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"certificate":{"cert":{"content":"cert-content","filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"content":"key-content","filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse1706264440"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"locations":["aws:us-east-2"],"message":"BDD
4-
test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1706264440","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1706264440","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}'
3+
body: '{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"certificate":{"cert":{"content":"cert-content","filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"content":"key-content","filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse1713355901"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"},"variablesFromScript":"dd.variable.set(\"FOO\",
4+
\"foo\")"},"locations":["aws:us-east-2"],"message":"BDD test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1713355901","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1713355901","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}'
55
headers:
66
accept:
77
- application/json
@@ -11,17 +11,19 @@ interactions:
1111
uri: https://api.datadoghq.com/api/v1/synthetics/tests/api
1212
response:
1313
body:
14-
string: '{"public_id":"vkt-349-4ey","name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1706264440","status":"live","type":"api","tags":["testing:api"],"created_at":"2024-01-26T10:20:41.088993+00:00","modified_at":"2024-01-26T10:20:41.088993+00:00","config":{"assertions":[{"operator":"is","property":"{{
15-
PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse1706264440"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"message":"BDD
16-
test payload: synthetics_api_http_test_payload.json","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1706264440","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"subtype":"http","created_by":{"name":"Frog","handle":"[email protected]","email":"[email protected]"},"deleted_at":null,"monitor_id":138446067,"org_id":569509,"modified_by":{"name":"Frog","handle":"[email protected]","email":"[email protected]"}}'
14+
string: '{"public_id":"9hn-bu2-s5b","name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1713355901","status":"live","type":"api","tags":["testing:api"],"created_at":"2024-04-17T12:11:41.303444+00:00","modified_at":"2024-04-17T12:11:41.303444+00:00","config":{"assertions":[{"operator":"is","property":"{{
15+
PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse1713355901"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"},"variablesFromScript":"dd.variable.set(\"FOO\",
16+
\"foo\")"},"message":"BDD test payload: synthetics_api_http_test_payload.json","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response-1713355901","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"subtype":"http","created_by":{"name":"CI
17+
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"[email protected]"},"deleted_at":null,"monitor_id":143340069,"org_id":321813,"modified_by":{"name":"CI
18+
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"[email protected]"}}'
1719
headers:
1820
content-type:
1921
- application/json
2022
status:
2123
code: 200
2224
message: OK
2325
- request:
24-
body: '{"public_ids":["vkt-349-4ey"]}'
26+
body: '{"public_ids":["9hn-bu2-s5b"]}'
2527
headers:
2628
accept:
2729
- application/json
@@ -31,7 +33,7 @@ interactions:
3133
uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete
3234
response:
3335
body:
34-
string: '{"deleted_tests":[{"public_id":"vkt-349-4ey","deleted_at":"2024-01-26T10:20:41.763678+00:00"}]}
36+
string: '{"deleted_tests":[{"public_id":"9hn-bu2-s5b","deleted_at":"2024-04-17T12:11:41.750987+00:00"}]}
3537
3638
'
3739
headers:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-01-26T10:20:48.691Z
1+
2024-04-17T12:11:42.640Z

0 commit comments

Comments
 (0)