Skip to content

Commit

Permalink
Add JSONSchema assertion support to API and multistep tests (#1925)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
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 committed Apr 22, 2024
1 parent dea346e commit dc9b08e
Show file tree
Hide file tree
Showing 30 changed files with 451 additions and 82 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-19 20:49:45.386499",
"spec_repo_commit": "c3db9ec1"
"regenerated": "2024-04-22 11:29:47.866511",
"spec_repo_commit": "0f37d2e6"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-04-19 20:49:45.403012",
"spec_repo_commit": "c3db9ec1"
"regenerated": "2024-04-22 11:29:47.883528",
"spec_repo_commit": "0f37d2e6"
}
}
}
40 changes: 40 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13627,6 +13627,7 @@ components:
oneOf:
- $ref: '#/components/schemas/SyntheticsAssertionTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJSONPathTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJSONSchemaTarget'
- $ref: '#/components/schemas/SyntheticsAssertionXPathTarget'
SyntheticsAssertionJSONPathOperator:
description: Assertion operator to apply.
Expand Down Expand Up @@ -13664,6 +13665,45 @@ components:
targetValue:
description: The path target value to compare to.
type: object
SyntheticsAssertionJSONSchemaMetaSchema:
description: The JSON Schema meta-schema version used in the assertion.
enum:
- draft-07
- draft-06
type: string
x-enum-varnames:
- DRAFT_07
- DRAFT_06
SyntheticsAssertionJSONSchemaOperator:
description: Assertion operator to apply.
enum:
- validatesJSONSchema
example: validatesJSONSchema
type: string
x-enum-varnames:
- VALIDATES_JSON_SCHEMA
SyntheticsAssertionJSONSchemaTarget:
description: An assertion for the `validatesJSONSchema` operator.
properties:
operator:
$ref: '#/components/schemas/SyntheticsAssertionJSONSchemaOperator'
target:
$ref: '#/components/schemas/SyntheticsAssertionJSONSchemaTargetTarget'
type:
$ref: '#/components/schemas/SyntheticsAssertionType'
required:
- type
- operator
type: object
SyntheticsAssertionJSONSchemaTargetTarget:
description: Composed target for `validatesJSONSchema` operator.
properties:
jsonSchema:
description: The JSON Schema to assert.
type: string
metaSchema:
$ref: '#/components/schemas/SyntheticsAssertionJSONSchemaMetaSchema'
type: object
SyntheticsAssertionOperator:
description: Assertion operator to apply.
enum:
Expand Down
28 changes: 28 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3865,6 +3865,34 @@ synthetics\_assertion\_json\_path\_target\_target
:members:
:show-inheritance:

synthetics\_assertion\_json\_schema\_meta\_schema
-------------------------------------------------

.. automodule:: datadog_api_client.v1.model.synthetics_assertion_json_schema_meta_schema
:members:
:show-inheritance:

synthetics\_assertion\_json\_schema\_operator
---------------------------------------------

.. automodule:: datadog_api_client.v1.model.synthetics_assertion_json_schema_operator
:members:
:show-inheritance:

synthetics\_assertion\_json\_schema\_target
-------------------------------------------

.. automodule:: datadog_api_client.v1.model.synthetics_assertion_json_schema_target
:members:
:show-inheritance:

synthetics\_assertion\_json\_schema\_target\_target
---------------------------------------------------

.. automodule:: datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target
:members:
:show-inheritance:

synthetics\_assertion\_operator
-------------------------------

Expand Down
16 changes: 16 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
SyntheticsAssertionJSONPathTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_meta_schema import (
SyntheticsAssertionJSONSchemaMetaSchema,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_operator import SyntheticsAssertionJSONSchemaOperator
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target import SyntheticsAssertionJSONSchemaTarget
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target import (
SyntheticsAssertionJSONSchemaTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_timings_scope import SyntheticsAssertionTimingsScope
Expand Down Expand Up @@ -60,6 +68,14 @@
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionJSONSchemaTarget(
operator=SyntheticsAssertionJSONSchemaOperator.VALIDATES_JSON_SCHEMA,
target=SyntheticsAssertionJSONSchemaTargetTarget(
meta_schema=SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_07,
json_schema='{"type": "object", "properties":{"slideshow":{"type":"object"}}}',
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionXPathTarget(
operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH,
target=SyntheticsAssertionXPathTargetTarget(
Expand Down
16 changes: 16 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_960766374.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
SyntheticsAssertionJSONPathTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_meta_schema import (
SyntheticsAssertionJSONSchemaMetaSchema,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_operator import SyntheticsAssertionJSONSchemaOperator
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target import SyntheticsAssertionJSONSchemaTarget
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target import (
SyntheticsAssertionJSONSchemaTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
Expand Down Expand Up @@ -57,6 +65,14 @@
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionJSONSchemaTarget(
operator=SyntheticsAssertionJSONSchemaOperator.VALIDATES_JSON_SCHEMA,
target=SyntheticsAssertionJSONSchemaTargetTarget(
meta_schema=SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_07,
json_schema='{"type": "object", "properties":{"slideshow":{"type":"object"}}}',
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionXPathTarget(
operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH,
target=SyntheticsAssertionXPathTargetTarget(
Expand Down
16 changes: 16 additions & 0 deletions examples/v1/synthetics/UpdateAPITest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
SyntheticsAssertionJSONPathTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_meta_schema import (
SyntheticsAssertionJSONSchemaMetaSchema,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_operator import SyntheticsAssertionJSONSchemaOperator
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target import SyntheticsAssertionJSONSchemaTarget
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target import (
SyntheticsAssertionJSONSchemaTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
Expand Down Expand Up @@ -53,6 +61,14 @@
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionJSONSchemaTarget(
operator=SyntheticsAssertionJSONSchemaOperator.VALIDATES_JSON_SCHEMA,
target=SyntheticsAssertionJSONSchemaTargetTarget(
meta_schema=SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_07,
json_schema='{"type": "object", "properties":{"slideshow":{"type":"object"}}}',
),
type=SyntheticsAssertionType.BODY,
),
],
config_variables=[
SyntheticsConfigVariable(
Expand Down
2 changes: 2 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 @@ -20,6 +20,7 @@
from datadog_api_client.v1.model.synthetics_api_step import SyntheticsAPIStep
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target import SyntheticsAssertionJSONSchemaTarget
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget


Expand Down Expand Up @@ -55,6 +56,7 @@ def __init__(
SyntheticsAssertion,
SyntheticsAssertionTarget,
SyntheticsAssertionJSONPathTarget,
SyntheticsAssertionJSONSchemaTarget,
SyntheticsAssertionXPathTarget,
]
],
Expand Down
4 changes: 4 additions & 0 deletions src/datadog_api_client/v1/model/synthetics_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ def _composed_schemas(_):
# loading
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target import (
SyntheticsAssertionJSONSchemaTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget

return {
"oneOf": [
SyntheticsAssertionTarget,
SyntheticsAssertionJSONPathTarget,
SyntheticsAssertionJSONSchemaTarget,
SyntheticsAssertionXPathTarget,
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class SyntheticsAssertionJSONSchemaMetaSchema(ModelSimple):
"""
The JSON Schema meta-schema version used in the assertion.
:param value: Must be one of ["draft-07", "draft-06"].
:type value: str
"""

allowed_values = {
"draft-07",
"draft-06",
}
DRAFT_07: ClassVar["SyntheticsAssertionJSONSchemaMetaSchema"]
DRAFT_06: ClassVar["SyntheticsAssertionJSONSchemaMetaSchema"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_07 = SyntheticsAssertionJSONSchemaMetaSchema("draft-07")
SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_06 = SyntheticsAssertionJSONSchemaMetaSchema("draft-06")
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class SyntheticsAssertionJSONSchemaOperator(ModelSimple):
"""
Assertion operator to apply.
:param value: If omitted defaults to "validatesJSONSchema". Must be one of ["validatesJSONSchema"].
:type value: str
"""

allowed_values = {
"validatesJSONSchema",
}
VALIDATES_JSON_SCHEMA: ClassVar["SyntheticsAssertionJSONSchemaOperator"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


SyntheticsAssertionJSONSchemaOperator.VALIDATES_JSON_SCHEMA = SyntheticsAssertionJSONSchemaOperator(
"validatesJSONSchema"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v1.model.synthetics_assertion_json_schema_operator import (
SyntheticsAssertionJSONSchemaOperator,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target import (
SyntheticsAssertionJSONSchemaTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType


class SyntheticsAssertionJSONSchemaTarget(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.synthetics_assertion_json_schema_operator import (
SyntheticsAssertionJSONSchemaOperator,
)
from datadog_api_client.v1.model.synthetics_assertion_json_schema_target_target import (
SyntheticsAssertionJSONSchemaTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType

return {
"operator": (SyntheticsAssertionJSONSchemaOperator,),
"target": (SyntheticsAssertionJSONSchemaTargetTarget,),
"type": (SyntheticsAssertionType,),
}

attribute_map = {
"operator": "operator",
"target": "target",
"type": "type",
}

def __init__(
self_,
operator: SyntheticsAssertionJSONSchemaOperator,
type: SyntheticsAssertionType,
target: Union[SyntheticsAssertionJSONSchemaTargetTarget, UnsetType] = unset,
**kwargs,
):
"""
An assertion for the ``validatesJSONSchema`` operator.
:param operator: Assertion operator to apply.
:type operator: SyntheticsAssertionJSONSchemaOperator
:param target: Composed target for ``validatesJSONSchema`` operator.
:type target: SyntheticsAssertionJSONSchemaTargetTarget, optional
:param type: Type of the assertion.
:type type: SyntheticsAssertionType
"""
if target is not unset:
kwargs["target"] = target
super().__init__(kwargs)

self_.operator = operator
self_.type = type
Loading

0 comments on commit dc9b08e

Please sign in to comment.