Skip to content

Commit eece91a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for xpath assertions in synthetics tests (#1204)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 6f3f4cc commit eece91a

21 files changed

+343
-50
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.4",
7-
"regenerated": "2022-11-04 18:42:27.825188",
8-
"spec_repo_commit": "af3f11fc"
7+
"regenerated": "2022-11-08 09:49:28.138621",
8+
"spec_repo_commit": "9146e44b"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-11-04 18:42:27.839660",
13-
"spec_repo_commit": "af3f11fc"
12+
"regenerated": "2022-11-08 09:49:28.149991",
13+
"spec_repo_commit": "9146e44b"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11299,6 +11299,7 @@ components:
1129911299
oneOf:
1130011300
- $ref: '#/components/schemas/SyntheticsAssertionTarget'
1130111301
- $ref: '#/components/schemas/SyntheticsAssertionJSONPathTarget'
11302+
- $ref: '#/components/schemas/SyntheticsAssertionXPathTarget'
1130211303
type: object
1130311304
SyntheticsAssertionJSONPathOperator:
1130411305
description: Assertion operator to apply.
@@ -11428,6 +11429,42 @@ components:
1142811429
- RECEIVED_MESSAGE
1142911430
- GRPC_HEALTHCHECK_STATUS
1143011431
- CONNECTION
11432+
SyntheticsAssertionXPathOperator:
11433+
description: Assertion operator to apply.
11434+
enum:
11435+
- validatesXPath
11436+
example: validatesXPath
11437+
type: string
11438+
x-enum-varnames:
11439+
- VALIDATES_X_PATH
11440+
SyntheticsAssertionXPathTarget:
11441+
description: An assertion for the `validatesXPath` operator.
11442+
properties:
11443+
operator:
11444+
$ref: '#/components/schemas/SyntheticsAssertionXPathOperator'
11445+
property:
11446+
description: The associated assertion property.
11447+
type: string
11448+
target:
11449+
$ref: '#/components/schemas/SyntheticsAssertionXPathTargetTarget'
11450+
type:
11451+
$ref: '#/components/schemas/SyntheticsAssertionType'
11452+
required:
11453+
- type
11454+
- operator
11455+
type: object
11456+
SyntheticsAssertionXPathTargetTarget:
11457+
description: Composed target for `validatesXPath` operator.
11458+
properties:
11459+
operator:
11460+
description: The specific operator to use on the path.
11461+
type: string
11462+
targetValue:
11463+
description: The path target value to compare to.
11464+
xPath:
11465+
description: The X path to assert.
11466+
type: string
11467+
type: object
1143111468
SyntheticsBasicAuth:
1143211469
description: Object to handle basic authentication when performing the test.
1143311470
oneOf:

docs/datadog_api_client.v1.model.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,27 @@ synthetics\_assertion\_type
33683368
:members:
33693369
:show-inheritance:
33703370

3371+
synthetics\_assertion\_x\_path\_operator
3372+
----------------------------------------
3373+
3374+
.. automodule:: datadog_api_client.v1.model.synthetics_assertion_x_path_operator
3375+
:members:
3376+
:show-inheritance:
3377+
3378+
synthetics\_assertion\_x\_path\_target
3379+
--------------------------------------
3380+
3381+
.. automodule:: datadog_api_client.v1.model.synthetics_assertion_x_path_target
3382+
:members:
3383+
:show-inheritance:
3384+
3385+
synthetics\_assertion\_x\_path\_target\_target
3386+
----------------------------------------------
3387+
3388+
.. automodule:: datadog_api_client.v1.model.synthetics_assertion_x_path_target_target
3389+
:members:
3390+
:show-inheritance:
3391+
33713392
synthetics\_basic\_auth
33723393
-----------------------
33733394

examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
1717
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
1818
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
19+
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
20+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
21+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget
1922
from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable
2023
from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType
2124
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
@@ -50,6 +53,15 @@
5053
),
5154
type=SyntheticsAssertionType.BODY,
5255
),
56+
SyntheticsAssertionXPathTarget(
57+
operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH,
58+
target=SyntheticsAssertionXPathTargetTarget(
59+
x_path="target-xpath",
60+
target_value="0",
61+
operator="contains",
62+
),
63+
type=SyntheticsAssertionType.BODY,
64+
),
5365
],
5466
config_variables=[
5567
SyntheticsConfigVariable(

src/datadog_api_client/v1/model/synthetics_api_test_config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from datadog_api_client.v1.model.synthetics_api_step import SyntheticsAPIStep
2121
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
2222
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
23+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
2324

2425

2526
class SyntheticsAPITestConfig(ModelNormal):
@@ -47,7 +48,15 @@ def openapi_types(_):
4748
def __init__(
4849
self_,
4950
assertions: Union[
50-
List[Union[SyntheticsAssertion, SyntheticsAssertionTarget, SyntheticsAssertionJSONPathTarget]], UnsetType
51+
List[
52+
Union[
53+
SyntheticsAssertion,
54+
SyntheticsAssertionTarget,
55+
SyntheticsAssertionJSONPathTarget,
56+
SyntheticsAssertionXPathTarget,
57+
]
58+
],
59+
UnsetType,
5160
] = unset,
5261
config_variables: Union[List[SyntheticsConfigVariable], UnsetType] = unset,
5362
request: Union[SyntheticsTestRequest, UnsetType] = unset,

src/datadog_api_client/v1/model/synthetics_assertion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ def _composed_schemas(_):
4141
# loading
4242
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
4343
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
44+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
4445

4546
return {
4647
"oneOf": [
4748
SyntheticsAssertionTarget,
4849
SyntheticsAssertionJSONPathTarget,
50+
SyntheticsAssertionXPathTarget,
4951
],
5052
}
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 SyntheticsAssertionXPathOperator(ModelSimple):
16+
"""
17+
Assertion operator to apply.
18+
19+
:param value: If omitted defaults to "validatesXPath". Must be one of ["validatesXPath"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"validatesXPath",
25+
}
26+
VALIDATES_X_PATH: ClassVar["SyntheticsAssertionXPathOperator"]
27+
28+
@cached_property
29+
def openapi_types(_):
30+
return {
31+
"value": (str,),
32+
}
33+
34+
35+
SyntheticsAssertionXPathOperator.VALIDATES_X_PATH = SyntheticsAssertionXPathOperator("validatesXPath")
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 TYPE_CHECKING, Union
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_assertion_x_path_operator import SyntheticsAssertionXPathOperator
18+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import (
19+
SyntheticsAssertionXPathTargetTarget,
20+
)
21+
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
22+
23+
24+
class SyntheticsAssertionXPathTarget(ModelNormal):
25+
@cached_property
26+
def openapi_types(_):
27+
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
28+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import (
29+
SyntheticsAssertionXPathTargetTarget,
30+
)
31+
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
32+
33+
return {
34+
"operator": (SyntheticsAssertionXPathOperator,),
35+
"_property": (str,),
36+
"target": (SyntheticsAssertionXPathTargetTarget,),
37+
"type": (SyntheticsAssertionType,),
38+
}
39+
40+
attribute_map = {
41+
"operator": "operator",
42+
"_property": "property",
43+
"target": "target",
44+
"type": "type",
45+
}
46+
47+
def __init__(
48+
self_,
49+
operator: SyntheticsAssertionXPathOperator,
50+
type: SyntheticsAssertionType,
51+
_property: Union[str, UnsetType] = unset,
52+
target: Union[SyntheticsAssertionXPathTargetTarget, UnsetType] = unset,
53+
**kwargs,
54+
):
55+
"""
56+
An assertion for the ``validatesXPath`` operator.
57+
58+
:param operator: Assertion operator to apply.
59+
:type operator: SyntheticsAssertionXPathOperator
60+
61+
:param _property: The associated assertion property.
62+
:type _property: str, optional
63+
64+
:param target: Composed target for ``validatesXPath`` operator.
65+
:type target: SyntheticsAssertionXPathTargetTarget, optional
66+
67+
:param type: Type of the assertion.
68+
:type type: SyntheticsAssertionType
69+
"""
70+
if _property is not unset:
71+
kwargs["_property"] = _property
72+
if target is not unset:
73+
kwargs["target"] = target
74+
super().__init__(kwargs)
75+
76+
self_.operator = operator
77+
self_.type = type
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 Any, Union
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
date,
12+
datetime,
13+
none_type,
14+
unset,
15+
UnsetType,
16+
)
17+
18+
19+
class SyntheticsAssertionXPathTargetTarget(ModelNormal):
20+
@cached_property
21+
def openapi_types(_):
22+
return {
23+
"operator": (str,),
24+
"target_value": (
25+
bool,
26+
date,
27+
datetime,
28+
dict,
29+
float,
30+
int,
31+
list,
32+
str,
33+
none_type,
34+
),
35+
"x_path": (str,),
36+
}
37+
38+
attribute_map = {
39+
"operator": "operator",
40+
"target_value": "targetValue",
41+
"x_path": "xPath",
42+
}
43+
44+
def __init__(
45+
self_,
46+
operator: Union[str, UnsetType] = unset,
47+
target_value: Union[Any, UnsetType] = unset,
48+
x_path: Union[str, UnsetType] = unset,
49+
**kwargs,
50+
):
51+
"""
52+
Composed target for ``validatesXPath`` operator.
53+
54+
:param operator: The specific operator to use on the path.
55+
:type operator: str, optional
56+
57+
:param target_value: The path target value to compare to.
58+
:type target_value: bool, date, datetime, dict, float, int, list, str, none_type, optional
59+
60+
:param x_path: The X path to assert.
61+
:type x_path: str, optional
62+
"""
63+
if operator is not unset:
64+
kwargs["operator"] = operator
65+
if target_value is not unset:
66+
kwargs["target_value"] = target_value
67+
if x_path is not unset:
68+
kwargs["x_path"] = x_path
69+
super().__init__(kwargs)

src/datadog_api_client/v1/model/synthetics_test_config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from datadog_api_client.v1.model.synthetics_browser_variable import SyntheticsBrowserVariable
2121
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
2222
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
23+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
2324

2425

2526
class SyntheticsTestConfig(ModelNormal):
@@ -47,7 +48,15 @@ def openapi_types(_):
4748
def __init__(
4849
self_,
4950
assertions: Union[
50-
List[Union[SyntheticsAssertion, SyntheticsAssertionTarget, SyntheticsAssertionJSONPathTarget]], UnsetType
51+
List[
52+
Union[
53+
SyntheticsAssertion,
54+
SyntheticsAssertionTarget,
55+
SyntheticsAssertionJSONPathTarget,
56+
SyntheticsAssertionXPathTarget,
57+
]
58+
],
59+
UnsetType,
5160
] = unset,
5261
config_variables: Union[List[SyntheticsConfigVariable], UnsetType] = unset,
5362
request: Union[SyntheticsTestRequest, UnsetType] = unset,

0 commit comments

Comments
 (0)