Skip to content

Commit

Permalink
Add bodyHash as a synthetics assertion type. (#1992)
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 Jun 10, 2024
1 parent 4b2d5fd commit c697997
Show file tree
Hide file tree
Showing 27 changed files with 540 additions and 61 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-06-07 12:30:49.616759",
"spec_repo_commit": "93296fc6"
"regenerated": "2024-06-10 14:07:14.105607",
"spec_repo_commit": "eaf0da43"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-07 12:30:49.634620",
"spec_repo_commit": "93296fc6"
"regenerated": "2024-06-10 14:07:14.122767",
"spec_repo_commit": "eaf0da43"
}
}
}
36 changes: 36 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13693,9 +13693,45 @@ components:
which property they apply, and upon which target.'
oneOf:
- $ref: '#/components/schemas/SyntheticsAssertionTarget'
- $ref: '#/components/schemas/SyntheticsAssertionBodyHashTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJSONPathTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJSONSchemaTarget'
- $ref: '#/components/schemas/SyntheticsAssertionXPathTarget'
SyntheticsAssertionBodyHashOperator:
description: Assertion operator to apply.
enum:
- md5
- sha1
- sha256
example: md5
type: string
x-enum-varnames:
- MD5
- SHA1
- SHA256
SyntheticsAssertionBodyHashTarget:
description: An assertion which targets body hash.
properties:
operator:
$ref: '#/components/schemas/SyntheticsAssertionBodyHashOperator'
target:
description: Value used by the operator.
example: 123456
type:
$ref: '#/components/schemas/SyntheticsAssertionBodyHashType'
required:
- type
- operator
- target
type: object
SyntheticsAssertionBodyHashType:
description: Type of the assertion.
enum:
- bodyHash
example: bodyHash
type: string
x-enum-varnames:
- BODY_HASH
SyntheticsAssertionJSONPathOperator:
description: Assertion operator to apply.
enum:
Expand Down
21 changes: 21 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3858,6 +3858,27 @@ synthetics\_assertion
:members:
:show-inheritance:

synthetics\_assertion\_body\_hash\_operator
-------------------------------------------

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

synthetics\_assertion\_body\_hash\_target
-----------------------------------------

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

synthetics\_assertion\_body\_hash\_type
---------------------------------------

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

synthetics\_assertion\_json\_path\_operator
-------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_body_hash_operator import SyntheticsAssertionBodyHashOperator
from datadog_api_client.v1.model.synthetics_assertion_body_hash_target import SyntheticsAssertionBodyHashTarget
from datadog_api_client.v1.model.synthetics_assertion_body_hash_type import SyntheticsAssertionBodyHashType
from datadog_api_client.v1.model.synthetics_assertion_json_path_operator import SyntheticsAssertionJSONPathOperator
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
Expand Down Expand Up @@ -85,6 +88,11 @@
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionBodyHashTarget(
operator=SyntheticsAssertionBodyHashOperator.MD5,
target="a",
type=SyntheticsAssertionBodyHashType.BODY_HASH,
),
],
config_variables=[
SyntheticsConfigVariable(
Expand Down
174 changes: 174 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
"""
Create an API HTTP test has bodyHash filled out
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_body_hash_operator import SyntheticsAssertionBodyHashOperator
from datadog_api_client.v1.model.synthetics_assertion_body_hash_target import SyntheticsAssertionBodyHashTarget
from datadog_api_client.v1.model.synthetics_assertion_body_hash_type import SyntheticsAssertionBodyHashType
from datadog_api_client.v1.model.synthetics_assertion_json_path_operator import SyntheticsAssertionJSONPathOperator
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
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
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client import SyntheticsBasicAuthOauthClient
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import SyntheticsBasicAuthOauthClientType
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
SyntheticsBasicAuthOauthTokenApiAuthentication,
)
from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable
from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v1.model.synthetics_test_options_http_version import SyntheticsTestOptionsHTTPVersion
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate
from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem
from datadog_api_client.v1.model.synthetics_test_request_proxy import SyntheticsTestRequestProxy

body = SyntheticsAPITest(
config=SyntheticsAPITestConfig(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
_property="{{ PROPERTY }}",
target="text/html",
type=SyntheticsAssertionType.HEADER,
),
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.LESS_THAN,
target=2000,
type=SyntheticsAssertionType.RESPONSE_TIME,
timings_scope=SyntheticsAssertionTimingsScope.WITHOUT_DNS,
),
SyntheticsAssertionJSONPathTarget(
operator=SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH,
target=SyntheticsAssertionJSONPathTargetTarget(
json_path="topKey",
operator="isNot",
target_value="0",
),
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(
x_path="target-xpath",
target_value="0",
operator="contains",
),
type=SyntheticsAssertionType.BODY,
),
SyntheticsAssertionBodyHashTarget(
operator=SyntheticsAssertionBodyHashOperator.MD5,
target="a",
type=SyntheticsAssertionBodyHashType.BODY_HASH,
),
],
config_variables=[
SyntheticsConfigVariable(
example="content-type",
name="PROPERTY",
pattern="content-type",
type=SyntheticsConfigVariableType.TEXT,
),
],
variables_from_script='dd.variable.set("FOO", "foo")',
request=SyntheticsTestRequest(
certificate=SyntheticsTestRequestCertificate(
cert=SyntheticsTestRequestCertificateItem(
content="cert-content",
filename="cert-filename",
updated_at="2020-10-16T09:23:24.857Z",
),
key=SyntheticsTestRequestCertificateItem(
content="key-content",
filename="key-filename",
updated_at="2020-10-16T09:23:24.857Z",
),
),
headers=SyntheticsTestHeaders(
unique="examplesynthetic",
),
method="GET",
timeout=10.0,
url="https://datadoghq.com",
proxy=SyntheticsTestRequestProxy(
url="https://datadoghq.com",
headers=SyntheticsTestHeaders(),
),
basic_auth=SyntheticsBasicAuthOauthClient(
access_token_url="https://datadog-token.com",
audience="audience",
client_id="client-id",
client_secret="client-secret",
resource="resource",
scope="yoyo",
token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.HEADER,
type=SyntheticsBasicAuthOauthClientType.OAUTH_CLIENT,
),
persist_cookies=True,
),
),
locations=[
"aws:us-east-2",
],
message="BDD test payload: synthetics_api_http_test_payload.json",
name="Example-Synthetic",
options=SyntheticsTestOptions(
accept_self_signed=False,
allow_insecure=True,
follow_redirects=True,
min_failure_duration=10,
min_location_failed=1,
monitor_name="Example-Synthetic",
monitor_priority=5,
retry=SyntheticsTestOptionsRetry(
count=3,
interval=10.0,
),
tick_every=60,
http_version=SyntheticsTestOptionsHTTPVersion.HTTP2,
),
subtype=SyntheticsTestDetailsSubType.HTTP,
tags=[
"testing:api",
],
type=SyntheticsAPITestType.API,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = SyntheticsApi(api_client)
response = api_instance.create_synthetics_api_test(body=body)

print(response)
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 @@ -19,6 +19,7 @@
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
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_body_hash_target import SyntheticsAssertionBodyHashTarget
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__(
Union[
SyntheticsAssertion,
SyntheticsAssertionTarget,
SyntheticsAssertionBodyHashTarget,
SyntheticsAssertionJSONPathTarget,
SyntheticsAssertionJSONSchemaTarget,
SyntheticsAssertionXPathTarget,
Expand Down
2 changes: 2 additions & 0 deletions src/datadog_api_client/v1/model/synthetics_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def _composed_schemas(_):
# classes don't exist yet because their module has not finished
# loading
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_body_hash_target import SyntheticsAssertionBodyHashTarget
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,
Expand All @@ -52,6 +53,7 @@ def _composed_schemas(_):
return {
"oneOf": [
SyntheticsAssertionTarget,
SyntheticsAssertionBodyHashTarget,
SyntheticsAssertionJSONPathTarget,
SyntheticsAssertionJSONSchemaTarget,
SyntheticsAssertionXPathTarget,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 SyntheticsAssertionBodyHashOperator(ModelSimple):
"""
Assertion operator to apply.
:param value: Must be one of ["md5", "sha1", "sha256"].
:type value: str
"""

allowed_values = {
"md5",
"sha1",
"sha256",
}
MD5: ClassVar["SyntheticsAssertionBodyHashOperator"]
SHA1: ClassVar["SyntheticsAssertionBodyHashOperator"]
SHA256: ClassVar["SyntheticsAssertionBodyHashOperator"]

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


SyntheticsAssertionBodyHashOperator.MD5 = SyntheticsAssertionBodyHashOperator("md5")
SyntheticsAssertionBodyHashOperator.SHA1 = SyntheticsAssertionBodyHashOperator("sha1")
SyntheticsAssertionBodyHashOperator.SHA256 = SyntheticsAssertionBodyHashOperator("sha256")
Loading

0 comments on commit c697997

Please sign in to comment.