Skip to content

Commit 38c0444

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add subtest for synthetics multistep tests (#3042)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent ef38fe0 commit 38c0444

12 files changed

+457
-1
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14766,6 +14766,61 @@ components:
1476614766
oneOf:
1476714767
- $ref: '#/components/schemas/SyntheticsAPITestStep'
1476814768
- $ref: '#/components/schemas/SyntheticsAPIWaitStep'
14769+
- $ref: '#/components/schemas/SyntheticsAPISubtestStep'
14770+
SyntheticsAPISubtestStep:
14771+
description: The subtest step used in a Synthetics multi-step API test.
14772+
properties:
14773+
allowFailure:
14774+
description: Determines whether or not to continue with test if this step
14775+
fails.
14776+
type: boolean
14777+
alwaysExecute:
14778+
description: A boolean set to always execute this step even if the previous
14779+
step failed or was skipped.
14780+
type: boolean
14781+
exitIfSucceed:
14782+
description: Determines whether or not to exit the test if the step succeeds.
14783+
type: boolean
14784+
extractedValuesFromScript:
14785+
description: Generate variables using JavaScript.
14786+
type: string
14787+
id:
14788+
description: ID of the step.
14789+
example: abc-def-123
14790+
readOnly: true
14791+
type: string
14792+
isCritical:
14793+
description: 'Determines whether or not to consider the entire test as failed
14794+
if this step fails.
14795+
14796+
Can be used only if `allowFailure` is `true`.'
14797+
type: boolean
14798+
name:
14799+
description: The name of the step.
14800+
example: Example step name
14801+
type: string
14802+
retry:
14803+
$ref: '#/components/schemas/SyntheticsTestOptionsRetry'
14804+
subtestPublicId:
14805+
description: Public ID of the test to be played as part of a `playSubTest`
14806+
step type.
14807+
example: ''
14808+
type: string
14809+
subtype:
14810+
$ref: '#/components/schemas/SyntheticsAPISubtestStepSubtype'
14811+
required:
14812+
- name
14813+
- subtype
14814+
- subtestPublicId
14815+
type: object
14816+
SyntheticsAPISubtestStepSubtype:
14817+
description: The subtype of the Synthetic multi-step API subtest step.
14818+
enum:
14819+
- playSubTest
14820+
example: playSubTest
14821+
type: string
14822+
x-enum-varnames:
14823+
- PLAY_SUB_TEST
1476914824
SyntheticsAPITest:
1477014825
description: Object containing details about a Synthetic API test.
1477114826
properties:

docs/datadog_api_client.v1.model.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,6 +4134,20 @@ datadog\_api\_client.v1.model.synthetics\_api\_step module
41344134
:members:
41354135
:show-inheritance:
41364136

4137+
datadog\_api\_client.v1.model.synthetics\_api\_subtest\_step module
4138+
-------------------------------------------------------------------
4139+
4140+
.. automodule:: datadog_api_client.v1.model.synthetics_api_subtest_step
4141+
:members:
4142+
:show-inheritance:
4143+
4144+
datadog\_api\_client.v1.model.synthetics\_api\_subtest\_step\_subtype module
4145+
----------------------------------------------------------------------------
4146+
4147+
.. automodule:: datadog_api_client.v1.model.synthetics_api_subtest_step_subtype
4148+
:members:
4149+
:show-inheritance:
4150+
41374151
datadog\_api\_client.v1.model.synthetics\_api\_test module
41384152
----------------------------------------------------------
41394153

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""
2+
Create a multistep test with subtest returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
8+
from datadog_api_client.v1.model.synthetics_api_subtest_step import SyntheticsAPISubtestStep
9+
from datadog_api_client.v1.model.synthetics_api_subtest_step_subtype import SyntheticsAPISubtestStepSubtype
10+
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
11+
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
12+
from datadog_api_client.v1.model.synthetics_api_test_step import SyntheticsAPITestStep
13+
from datadog_api_client.v1.model.synthetics_api_test_step_subtype import SyntheticsAPITestStepSubtype
14+
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
15+
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
16+
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
17+
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
18+
from datadog_api_client.v1.model.synthetics_basic_auth_web import SyntheticsBasicAuthWeb
19+
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
20+
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
21+
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
22+
23+
# there is a valid "synthetics_api_test" in the system
24+
SYNTHETICS_API_TEST_PUBLIC_ID = environ["SYNTHETICS_API_TEST_PUBLIC_ID"]
25+
26+
body = SyntheticsAPITest(
27+
config=SyntheticsAPITestConfig(
28+
steps=[
29+
SyntheticsAPITestStep(
30+
assertions=[
31+
SyntheticsAssertionTarget(
32+
operator=SyntheticsAssertionOperator.IS,
33+
type=SyntheticsAssertionType.STATUS_CODE,
34+
target=200,
35+
),
36+
],
37+
name="request is sent",
38+
request=SyntheticsTestRequest(
39+
url="https://httpbin.org/status/200",
40+
method="GET",
41+
basic_auth=SyntheticsBasicAuthWeb(
42+
password="password",
43+
username="username",
44+
),
45+
),
46+
subtype=SyntheticsAPITestStepSubtype.HTTP,
47+
),
48+
SyntheticsAPISubtestStep(
49+
subtype=SyntheticsAPISubtestStepSubtype.PLAY_SUB_TEST,
50+
subtest_public_id=SYNTHETICS_API_TEST_PUBLIC_ID,
51+
name="subtest step",
52+
),
53+
],
54+
),
55+
locations=[
56+
"aws:us-east-2",
57+
],
58+
message="BDD test payload: synthetics_api_test_multi_step_with_subtest.json",
59+
name="Example-Synthetic",
60+
options=SyntheticsTestOptions(
61+
tick_every=60,
62+
),
63+
subtype=SyntheticsTestDetailsSubType.MULTI,
64+
type=SyntheticsAPITestType.API,
65+
)
66+
67+
configuration = Configuration()
68+
with ApiClient(configuration) as api_client:
69+
api_instance = SyntheticsApi(api_client)
70+
response = api_instance.create_synthetics_api_test(body=body)
71+
72+
print(response)

src/datadog_api_client/v1/model/synthetics_api_step.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def __init__(self, **kwargs):
5151
5252
:param value: The time to wait in seconds. Minimum value: 0. Maximum value: 180.
5353
:type value: int
54+
55+
:param always_execute: A boolean set to always execute this step even if the previous step failed or was skipped.
56+
:type always_execute: bool, optional
57+
58+
:param subtest_public_id: Public ID of the test to be played as part of a `playSubTest` step type.
59+
:type subtest_public_id: str
5460
"""
5561
super().__init__(kwargs)
5662

@@ -65,10 +71,12 @@ def _composed_schemas(_):
6571
# loading
6672
from datadog_api_client.v1.model.synthetics_api_test_step import SyntheticsAPITestStep
6773
from datadog_api_client.v1.model.synthetics_api_wait_step import SyntheticsAPIWaitStep
74+
from datadog_api_client.v1.model.synthetics_api_subtest_step import SyntheticsAPISubtestStep
6875

6976
return {
7077
"oneOf": [
7178
SyntheticsAPITestStep,
7279
SyntheticsAPIWaitStep,
80+
SyntheticsAPISubtestStep,
7381
],
7482
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
18+
from datadog_api_client.v1.model.synthetics_api_subtest_step_subtype import SyntheticsAPISubtestStepSubtype
19+
20+
21+
class SyntheticsAPISubtestStep(ModelNormal):
22+
@cached_property
23+
def openapi_types(_):
24+
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
25+
from datadog_api_client.v1.model.synthetics_api_subtest_step_subtype import SyntheticsAPISubtestStepSubtype
26+
27+
return {
28+
"allow_failure": (bool,),
29+
"always_execute": (bool,),
30+
"exit_if_succeed": (bool,),
31+
"extracted_values_from_script": (str,),
32+
"id": (str,),
33+
"is_critical": (bool,),
34+
"name": (str,),
35+
"retry": (SyntheticsTestOptionsRetry,),
36+
"subtest_public_id": (str,),
37+
"subtype": (SyntheticsAPISubtestStepSubtype,),
38+
}
39+
40+
attribute_map = {
41+
"allow_failure": "allowFailure",
42+
"always_execute": "alwaysExecute",
43+
"exit_if_succeed": "exitIfSucceed",
44+
"extracted_values_from_script": "extractedValuesFromScript",
45+
"id": "id",
46+
"is_critical": "isCritical",
47+
"name": "name",
48+
"retry": "retry",
49+
"subtest_public_id": "subtestPublicId",
50+
"subtype": "subtype",
51+
}
52+
read_only_vars = {
53+
"id",
54+
}
55+
56+
def __init__(
57+
self_,
58+
name: str,
59+
subtest_public_id: str,
60+
subtype: SyntheticsAPISubtestStepSubtype,
61+
allow_failure: Union[bool, UnsetType] = unset,
62+
always_execute: Union[bool, UnsetType] = unset,
63+
exit_if_succeed: Union[bool, UnsetType] = unset,
64+
extracted_values_from_script: Union[str, UnsetType] = unset,
65+
id: Union[str, UnsetType] = unset,
66+
is_critical: Union[bool, UnsetType] = unset,
67+
retry: Union[SyntheticsTestOptionsRetry, UnsetType] = unset,
68+
**kwargs,
69+
):
70+
"""
71+
The subtest step used in a Synthetics multi-step API test.
72+
73+
:param allow_failure: Determines whether or not to continue with test if this step fails.
74+
:type allow_failure: bool, optional
75+
76+
:param always_execute: A boolean set to always execute this step even if the previous step failed or was skipped.
77+
:type always_execute: bool, optional
78+
79+
:param exit_if_succeed: Determines whether or not to exit the test if the step succeeds.
80+
:type exit_if_succeed: bool, optional
81+
82+
:param extracted_values_from_script: Generate variables using JavaScript.
83+
:type extracted_values_from_script: str, optional
84+
85+
:param id: ID of the step.
86+
:type id: str, optional
87+
88+
:param is_critical: Determines whether or not to consider the entire test as failed if this step fails.
89+
Can be used only if ``allowFailure`` is ``true``.
90+
:type is_critical: bool, optional
91+
92+
:param name: The name of the step.
93+
:type name: str
94+
95+
:param retry: Object describing the retry strategy to apply to a Synthetic test.
96+
:type retry: SyntheticsTestOptionsRetry, optional
97+
98+
:param subtest_public_id: Public ID of the test to be played as part of a ``playSubTest`` step type.
99+
:type subtest_public_id: str
100+
101+
:param subtype: The subtype of the Synthetic multi-step API subtest step.
102+
:type subtype: SyntheticsAPISubtestStepSubtype
103+
"""
104+
if allow_failure is not unset:
105+
kwargs["allow_failure"] = allow_failure
106+
if always_execute is not unset:
107+
kwargs["always_execute"] = always_execute
108+
if exit_if_succeed is not unset:
109+
kwargs["exit_if_succeed"] = exit_if_succeed
110+
if extracted_values_from_script is not unset:
111+
kwargs["extracted_values_from_script"] = extracted_values_from_script
112+
if id is not unset:
113+
kwargs["id"] = id
114+
if is_critical is not unset:
115+
kwargs["is_critical"] = is_critical
116+
if retry is not unset:
117+
kwargs["retry"] = retry
118+
super().__init__(kwargs)
119+
120+
self_.name = name
121+
self_.subtest_public_id = subtest_public_id
122+
self_.subtype = subtype
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class SyntheticsAPISubtestStepSubtype(ModelSimple):
16+
"""
17+
The subtype of the Synthetic multi-step API subtest step.
18+
19+
:param value: If omitted defaults to "playSubTest". Must be one of ["playSubTest"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"playSubTest",
25+
}
26+
PLAY_SUB_TEST: ClassVar["SyntheticsAPISubtestStepSubtype"]
27+
28+
@cached_property
29+
def openapi_types(_):
30+
return {
31+
"value": (str,),
32+
}
33+
34+
35+
SyntheticsAPISubtestStepSubtype.PLAY_SUB_TEST = SyntheticsAPISubtestStepSubtype("playSubTest")

src/datadog_api_client/v1/model/synthetics_api_test_config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from datadog_api_client.v1.model.synthetics_assertion_javascript import SyntheticsAssertionJavascript
2727
from datadog_api_client.v1.model.synthetics_api_test_step import SyntheticsAPITestStep
2828
from datadog_api_client.v1.model.synthetics_api_wait_step import SyntheticsAPIWaitStep
29+
from datadog_api_client.v1.model.synthetics_api_subtest_step import SyntheticsAPISubtestStep
2930

3031

3132
class SyntheticsAPITestConfig(ModelNormal):
@@ -70,7 +71,10 @@ def __init__(
7071
] = unset,
7172
config_variables: Union[List[SyntheticsConfigVariable], UnsetType] = unset,
7273
request: Union[SyntheticsTestRequest, UnsetType] = unset,
73-
steps: Union[List[Union[SyntheticsAPIStep, SyntheticsAPITestStep, SyntheticsAPIWaitStep]], UnsetType] = unset,
74+
steps: Union[
75+
List[Union[SyntheticsAPIStep, SyntheticsAPITestStep, SyntheticsAPIWaitStep, SyntheticsAPISubtestStep]],
76+
UnsetType,
77+
] = unset,
7478
variables_from_script: Union[str, UnsetType] = unset,
7579
**kwargs,
7680
):

src/datadog_api_client/v1/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@
676676
from datadog_api_client.v1.model.sunburst_widget_legend_table_type import SunburstWidgetLegendTableType
677677
from datadog_api_client.v1.model.sunburst_widget_request import SunburstWidgetRequest
678678
from datadog_api_client.v1.model.synthetics_api_step import SyntheticsAPIStep
679+
from datadog_api_client.v1.model.synthetics_api_subtest_step import SyntheticsAPISubtestStep
680+
from datadog_api_client.v1.model.synthetics_api_subtest_step_subtype import SyntheticsAPISubtestStepSubtype
679681
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
680682
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
681683
from datadog_api_client.v1.model.synthetics_api_test_result_data import SyntheticsAPITestResultData
@@ -1725,6 +1727,8 @@
17251727
"SunburstWidgetLegendTableType",
17261728
"SunburstWidgetRequest",
17271729
"SyntheticsAPIStep",
1730+
"SyntheticsAPISubtestStep",
1731+
"SyntheticsAPISubtestStepSubtype",
17281732
"SyntheticsAPITest",
17291733
"SyntheticsAPITestConfig",
17301734
"SyntheticsAPITestResultData",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-12-26T15:22:45.114Z

0 commit comments

Comments
 (0)