Skip to content

Commit

Permalink
Add support variablesFromScript in Synthetics API test (#1945)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Apr 18, 2024
1 parent 6166914 commit 5dff910
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 60 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-04-15 13:32:56.776195",
"spec_repo_commit": "5c7e123b"
"regenerated": "2024-04-17 15:28:03.856507",
"spec_repo_commit": "4bea6a2f"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-04-15 13:32:56.793599",
"spec_repo_commit": "5c7e123b"
"regenerated": "2024-04-17 15:28:03.873583",
"spec_repo_commit": "4bea6a2f"
}
}
}
4 changes: 4 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13446,6 +13446,10 @@ components:
items:
$ref: '#/components/schemas/SyntheticsAPIStep'
type: array
variablesFromScript:
description: Variables defined from JavaScript code.
example: dd.variable.set("FOO", "foo")
type: string
type: object
SyntheticsAPITestResultData:
description: Object containing results for your Synthetic API test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
type=SyntheticsConfigVariableType.TEXT,
),
],
variables_from_script='dd.variable.set("FOO", "foo")',
request=SyntheticsTestRequest(
certificate=SyntheticsTestRequestCertificate(
cert=SyntheticsTestRequestCertificateItem(
Expand Down
8 changes: 8 additions & 0 deletions src/datadog_api_client/v1/model/synthetics_api_test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ def openapi_types(_):
"config_variables": ([SyntheticsConfigVariable],),
"request": (SyntheticsTestRequest,),
"steps": ([SyntheticsAPIStep],),
"variables_from_script": (str,),
}

attribute_map = {
"assertions": "assertions",
"config_variables": "configVariables",
"request": "request",
"steps": "steps",
"variables_from_script": "variablesFromScript",
}

def __init__(
Expand All @@ -61,6 +63,7 @@ def __init__(
config_variables: Union[List[SyntheticsConfigVariable], UnsetType] = unset,
request: Union[SyntheticsTestRequest, UnsetType] = unset,
steps: Union[List[SyntheticsAPIStep], UnsetType] = unset,
variables_from_script: Union[str, UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -77,6 +80,9 @@ def __init__(
:param steps: When the test subtype is ``multi`` , the steps of the test.
:type steps: [SyntheticsAPIStep], optional
:param variables_from_script: Variables defined from JavaScript code.
:type variables_from_script: str, optional
"""
if assertions is not unset:
kwargs["assertions"] = assertions
Expand All @@ -86,4 +92,6 @@ def __init__(
kwargs["request"] = request
if steps is not unset:
kwargs["steps"] = steps
if variables_from_script is not unset:
kwargs["variables_from_script"] = variables_from_script
super().__init__(kwargs)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-01-26T10:20:40.621Z
2024-04-17T12:11:41.063Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
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
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"}'
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\",
\"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"}'
headers:
accept:
- application/json
Expand All @@ -11,17 +11,19 @@ interactions:
uri: https://api.datadoghq.com/api/v1/synthetics/tests/api
response:
body:
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":"{{
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
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]"}}'
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":"{{
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\",
\"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
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"[email protected]"},"deleted_at":null,"monitor_id":143340069,"org_id":321813,"modified_by":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"[email protected]"}}'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: '{"public_ids":["vkt-349-4ey"]}'
body: '{"public_ids":["9hn-bu2-s5b"]}'
headers:
accept:
- application/json
Expand All @@ -31,7 +33,7 @@ interactions:
uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete
response:
body:
string: '{"deleted_tests":[{"public_id":"vkt-349-4ey","deleted_at":"2024-01-26T10:20:41.763678+00:00"}]}
string: '{"deleted_tests":[{"public_id":"9hn-bu2-s5b","deleted_at":"2024-04-17T12:11:41.750987+00:00"}]}
'
headers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-01-26T10:20:48.691Z
2024-04-17T12:11:42.640Z
Loading

0 comments on commit 5dff910

Please sign in to comment.