From 6e9fde14bf8467b416f7ab110c96529da98a96cb Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Wed, 14 May 2025 14:14:38 -0400 Subject: [PATCH 1/3] fix value generation --- .generator/src/generator/formatter.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.generator/src/generator/formatter.py b/.generator/src/generator/formatter.py index ea40a294be7..ab597c6302d 100644 --- a/.generator/src/generator/formatter.py +++ b/.generator/src/generator/formatter.py @@ -392,6 +392,16 @@ def format_double(x): raise TypeError(f"{x} is not supported type {schema}") return float(x) + def format_int(x): + if isinstance(x, str): + raise TypeError(f"{x} is not supported type {schema}") + return str(x) + + def format_int64(x): + if isinstance(x, str): + raise TypeError(f"{x} is not supported type {schema}") + return str(x) + "L" + def format_string(x): if isinstance(x, bool): raise TypeError(f"{x} is not supported type {schema}") @@ -425,8 +435,8 @@ def open_file(x): return f"new File({format_string(x)})" formatters = { - "int32": lambda x: str(int(x)), - "int64": lambda x: str(int(x)) + "L", + "int32": format_int, + "int64": format_int64, "double": format_double, "date-time": format_datetime, "number": format_number, From 0098765a8dfc30474b48147bb902e1f095c81f14 Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Thu, 22 May 2025 15:52:10 -0400 Subject: [PATCH 2/3] add support for double and other edge cases --- .generator/src/generator/formatter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.generator/src/generator/formatter.py b/.generator/src/generator/formatter.py index ab597c6302d..1491b9da6a4 100644 --- a/.generator/src/generator/formatter.py +++ b/.generator/src/generator/formatter.py @@ -383,22 +383,22 @@ def format_data_with_schema( else: def format_number(x): - if isinstance(x, bool): + if isinstance(x, bool | str): raise TypeError(f"{x} is not supported type {schema}") return str(x) def format_double(x): - if isinstance(x, bool): + if isinstance(x, bool | str): raise TypeError(f"{x} is not supported type {schema}") return float(x) def format_int(x): - if isinstance(x, str): + if isinstance(x, bool | str): raise TypeError(f"{x} is not supported type {schema}") return str(x) def format_int64(x): - if isinstance(x, str): + if isinstance(x, bool | str): raise TypeError(f"{x} is not supported type {schema}") return str(x) + "L" From 5e81df76fe0f3efc99c0bd990214e2b8d59a7c21 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 23 May 2025 12:50:14 +0000 Subject: [PATCH 3/3] Regenerate client from commit 11a9dcb4 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 20 +- .../synthetics/CreateSyntheticsAPITest.java | 3 +- .../CreateSyntheticsAPITest_1072503741.java | 3 +- .../CreateSyntheticsAPITest_1241981394.java | 9 +- .../CreateSyntheticsAPITest_1279271422.java | 9 +- .../CreateSyntheticsAPITest_1402674167.java | 7 +- .../CreateSyntheticsAPITest_1487281163.java | 13 +- .../CreateSyntheticsAPITest_1717840259.java | 29 +- .../CreateSyntheticsAPITest_1987645492.java | 13 +- .../CreateSyntheticsAPITest_2472747642.java | 5 +- .../CreateSyntheticsAPITest_3829801148.java | 5 +- .../CreateSyntheticsAPITest_960766374.java | 9 +- examples/v1/synthetics/UpdateAPITest.java | 7 +- .../SyntheticsAssertionBodyHashTarget.java | 15 +- ...ntheticsAssertionJSONPathTargetTarget.java | 12 +- .../v1/model/SyntheticsAssertionTarget.java | 15 +- .../model/SyntheticsAssertionTargetValue.java | 276 ++++++++++++++++++ .../SyntheticsAssertionXPathTargetTarget.java | 12 +- 19 files changed, 401 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTargetValue.java diff --git a/.apigentools-info b/.apigentools-info index b819d4df61f..8da1cbbbb8c 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-20 07:21:26.115507", - "spec_repo_commit": "fec20f97" + "regenerated": "2025-05-23 12:48:19.641798", + "spec_repo_commit": "11a9dcb4" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-20 07:21:26.131253", - "spec_repo_commit": "fec20f97" + "regenerated": "2025-05-23 12:48:19.657459", + "spec_repo_commit": "11a9dcb4" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index bfe39072ee5..1160834c2db 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -14221,8 +14221,8 @@ components: operator: $ref: '#/components/schemas/SyntheticsAssertionBodyHashOperator' target: + $ref: '#/components/schemas/SyntheticsAssertionTargetValue' description: Value used by the operator. - example: 123456 type: $ref: '#/components/schemas/SyntheticsAssertionBodyHashType' required: @@ -14278,6 +14278,7 @@ components: description: The specific operator to use on the path. type: string targetValue: + $ref: '#/components/schemas/SyntheticsAssertionTargetValue' description: The path target value to compare to. type: object SyntheticsAssertionJSONSchemaMetaSchema: @@ -14385,8 +14386,8 @@ components: description: The associated assertion property. type: string target: + $ref: '#/components/schemas/SyntheticsAssertionTargetValue' description: Value used by the operator. - example: 123456 timingsScope: $ref: '#/components/schemas/SyntheticsAssertionTimingsScope' type: @@ -14396,6 +14397,20 @@ components: - operator - target type: object + SyntheticsAssertionTargetValue: + description: Value used by the operator in assertions. Can be either a number + or string. + oneOf: + - $ref: '#/components/schemas/SyntheticsAssertionTargetValueNumber' + - $ref: '#/components/schemas/SyntheticsAssertionTargetValueString' + SyntheticsAssertionTargetValueNumber: + description: Numeric value used by the operator in assertions. + format: double + type: number + SyntheticsAssertionTargetValueString: + description: String value used by the operator in assertions. Supports templated + variables. + type: string SyntheticsAssertionTimingsScope: description: Timings scope for response time assertions. enum: @@ -14480,6 +14495,7 @@ components: description: The specific operator to use on the path. type: string targetValue: + $ref: '#/components/schemas/SyntheticsAssertionTargetValue' description: The path target value to compare to. xPath: description: The X path to assert. diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest.java b/examples/v1/synthetics/CreateSyntheticsAPITest.java index 13c330cafa9..b8a4bdebb2d 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest.java @@ -9,6 +9,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsBrowserTestRumSettings; import com.datadog.api.client.v1.model.SyntheticsTestCiOptions; @@ -40,7 +41,7 @@ public static void main(String[] args) { new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(1000) + .target(new SyntheticsAssertionTargetValue(1000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME)))) .request(new SyntheticsTestRequest().method("GET").url("https://example.com"))) .locations(Collections.singletonList("aws:eu-west-3")) diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1072503741.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1072503741.java index 6250a469b65..73f276eb488 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1072503741.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1072503741.java @@ -9,6 +9,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType; import com.datadog.api.client.v1.model.SyntheticsTestOptions; @@ -30,7 +31,7 @@ public static void main(String[] args) { new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS_IN_MORE_DAYS_THAN) - .target(10) + .target(new SyntheticsAssertionTargetValue(10.0)) .type(SyntheticsAssertionType.CERTIFICATE)))) .request( new SyntheticsTestRequest() diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.java index c58de6b5ab8..a95422ca3cb 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.java @@ -12,6 +12,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertionJSONPathTargetTarget; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator; @@ -52,12 +53,12 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .property("{{ PROPERTY }}") - .target("text/html") + .target(new SyntheticsAssertionTargetValue("text/html")) .type(SyntheticsAssertionType.HEADER)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME) .timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)), new SyntheticsAssertion( @@ -68,7 +69,7 @@ public static void main(String[] args) { new SyntheticsAssertionJSONPathTargetTarget() .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionXPathTarget() @@ -76,7 +77,7 @@ public static void main(String[] args) { .target( new SyntheticsAssertionXPathTargetTarget() .xPath("target-xpath") - .targetValue("0") + .targetValue(new SyntheticsAssertionTargetValue("0")) .operator("contains")) .type(SyntheticsAssertionType.BODY)))) .configVariables( diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1279271422.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1279271422.java index 6c4d62d9182..7d6b37bdcc5 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1279271422.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1279271422.java @@ -14,6 +14,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsConfigVariable; import com.datadog.api.client.v1.model.SyntheticsConfigVariableType; @@ -59,7 +60,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .exitIfSucceed(true) .extractedValues( Collections.singletonList( @@ -106,7 +109,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) .type(SyntheticsAssertionType.RESPONSE_TIME) - .target(1000)))) + .target( + new SyntheticsAssertionTargetValue( + 1000.0))))) .request( new SyntheticsTestRequest() .host("grpcbin.test.k6.io") diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1402674167.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1402674167.java index 1e3c8ca56a9..83660e61952 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1402674167.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1402674167.java @@ -9,6 +9,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType; import com.datadog.api.client.v1.model.SyntheticsTestOptions; @@ -33,17 +34,17 @@ public static void main(String[] args) { new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) - .target(1) + .target(new SyntheticsAssertionTargetValue(1.0)) .type(SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) - .target("proto target") + .target(new SyntheticsAssertionTargetValue("proto target")) .type(SyntheticsAssertionType.GRPC_PROTO)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) - .target("123") + .target(new SyntheticsAssertionTargetValue("123")) .property("property") .type(SyntheticsAssertionType.GRPC_METADATA)))) .request( diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.java index 4a6bf0fc503..dc264ec07c7 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.java @@ -21,6 +21,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertionJavascriptType; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator; @@ -59,12 +60,12 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .property("{{ PROPERTY }}") - .target("text/html") + .target(new SyntheticsAssertionTargetValue("text/html")) .type(SyntheticsAssertionType.HEADER)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME) .timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)), new SyntheticsAssertion( @@ -75,7 +76,7 @@ public static void main(String[] args) { new SyntheticsAssertionJSONPathTargetTarget() .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONPathTarget() @@ -86,7 +87,7 @@ public static void main(String[] args) { .elementsOperator("atLeastOneElementMatches") .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONSchemaTarget() @@ -107,13 +108,13 @@ public static void main(String[] args) { .target( new SyntheticsAssertionXPathTargetTarget() .xPath("target-xpath") - .targetValue("0") + .targetValue(new SyntheticsAssertionTargetValue("0")) .operator("contains")) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionBodyHashTarget() .operator(SyntheticsAssertionBodyHashOperator.MD5) - .target("a") + .target(new SyntheticsAssertionTargetValue("a")) .type(SyntheticsAssertionBodyHashType.BODY_HASH)), new SyntheticsAssertion( new SyntheticsAssertionJavascript() diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1717840259.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1717840259.java index cc8ffa5ec18..0fef826cc42 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1717840259.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1717840259.java @@ -13,6 +13,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsBasicAuth; import com.datadog.api.client.v1.model.SyntheticsBasicAuthDigest; @@ -53,7 +54,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -73,7 +76,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -94,7 +99,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -115,7 +122,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -134,7 +143,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -156,7 +167,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() @@ -183,7 +196,9 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .type(SyntheticsAssertionType.STATUS_CODE) - .target(200)))) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) .name("request is sent") .request( new SyntheticsTestRequest() diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.java b/examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.java index a401de69e0b..f1c54884f8e 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.java @@ -21,6 +21,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertionJavascriptType; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator; @@ -59,12 +60,12 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .property("{{ PROPERTY }}") - .target("text/html") + .target(new SyntheticsAssertionTargetValue("text/html")) .type(SyntheticsAssertionType.HEADER)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME) .timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)), new SyntheticsAssertion( @@ -75,7 +76,7 @@ public static void main(String[] args) { new SyntheticsAssertionJSONPathTargetTarget() .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONPathTarget() @@ -86,7 +87,7 @@ public static void main(String[] args) { .elementsOperator("atLeastOneElementMatches") .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONSchemaTarget() @@ -107,13 +108,13 @@ public static void main(String[] args) { .target( new SyntheticsAssertionXPathTargetTarget() .xPath("target-xpath") - .targetValue("0") + .targetValue(new SyntheticsAssertionTargetValue("0")) .operator("contains")) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionBodyHashTarget() .operator(SyntheticsAssertionBodyHashOperator.MD5) - .target("a") + .target(new SyntheticsAssertionTargetValue("a")) .type(SyntheticsAssertionBodyHashType.BODY_HASH)), new SyntheticsAssertion( new SyntheticsAssertionJavascript() diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_2472747642.java b/examples/v1/synthetics/CreateSyntheticsAPITest_2472747642.java index d9af3c3e160..d3489b9b7b9 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_2472747642.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_2472747642.java @@ -10,6 +10,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType; import com.datadog.api.client.v1.model.SyntheticsTestOptions; @@ -32,12 +33,12 @@ public static void main(String[] args) { new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) - .target("message") + .target(new SyntheticsAssertionTargetValue("message")) .type(SyntheticsAssertionType.RECEIVED_MESSAGE)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME)))) .request( new SyntheticsTestRequest().url("ws://datadoghq.com").message("message"))) diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_3829801148.java b/examples/v1/synthetics/CreateSyntheticsAPITest_3829801148.java index f72f9d16e1a..69005eceb34 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_3829801148.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_3829801148.java @@ -9,6 +9,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertion; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType; import com.datadog.api.client.v1.model.SyntheticsTestOptions; @@ -32,12 +33,12 @@ public static void main(String[] args) { new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) - .target("message") + .target(new SyntheticsAssertionTargetValue("message")) .type(SyntheticsAssertionType.RECEIVED_MESSAGE)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME)))) .request( new SyntheticsTestRequest() diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_960766374.java b/examples/v1/synthetics/CreateSyntheticsAPITest_960766374.java index a0ebabb762e..9e4ec6a1691 100644 --- a/examples/v1/synthetics/CreateSyntheticsAPITest_960766374.java +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_960766374.java @@ -16,6 +16,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertionJSONSchemaTargetTarget; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionXPathTarget; @@ -52,12 +53,12 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .property("{{ PROPERTY }}") - .target("text/html") + .target(new SyntheticsAssertionTargetValue("text/html")) .type(SyntheticsAssertionType.HEADER)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME)), new SyntheticsAssertion( new SyntheticsAssertionJSONPathTarget() @@ -67,7 +68,7 @@ public static void main(String[] args) { new SyntheticsAssertionJSONPathTargetTarget() .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONSchemaTarget() @@ -88,7 +89,7 @@ public static void main(String[] args) { .target( new SyntheticsAssertionXPathTargetTarget() .xPath("target-xpath") - .targetValue("0") + .targetValue(new SyntheticsAssertionTargetValue("0")) .operator("contains")) .type(SyntheticsAssertionType.BODY)))) .configVariables( diff --git a/examples/v1/synthetics/UpdateAPITest.java b/examples/v1/synthetics/UpdateAPITest.java index fc42b6978bc..dea518ec5ed 100644 --- a/examples/v1/synthetics/UpdateAPITest.java +++ b/examples/v1/synthetics/UpdateAPITest.java @@ -16,6 +16,7 @@ import com.datadog.api.client.v1.model.SyntheticsAssertionJSONSchemaTargetTarget; import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; import com.datadog.api.client.v1.model.SyntheticsAssertionType; import com.datadog.api.client.v1.model.SyntheticsConfigVariable; import com.datadog.api.client.v1.model.SyntheticsConfigVariableType; @@ -48,12 +49,12 @@ public static void main(String[] args) { new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.IS) .property("{{ PROPERTY }}") - .target("text/html") + .target(new SyntheticsAssertionTargetValue("text/html")) .type(SyntheticsAssertionType.HEADER)), new SyntheticsAssertion( new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.LESS_THAN) - .target(2000) + .target(new SyntheticsAssertionTargetValue(2000.0)) .type(SyntheticsAssertionType.RESPONSE_TIME)), new SyntheticsAssertion( new SyntheticsAssertionJSONPathTarget() @@ -63,7 +64,7 @@ public static void main(String[] args) { new SyntheticsAssertionJSONPathTargetTarget() .jsonPath("topKey") .operator("isNot") - .targetValue("0")) + .targetValue(new SyntheticsAssertionTargetValue("0"))) .type(SyntheticsAssertionType.BODY)), new SyntheticsAssertion( new SyntheticsAssertionJSONSchemaTarget() diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionBodyHashTarget.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionBodyHashTarget.java index 50b49d040a1..e2d441b46b0 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionBodyHashTarget.java +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionBodyHashTarget.java @@ -31,7 +31,7 @@ public class SyntheticsAssertionBodyHashTarget { private SyntheticsAssertionBodyHashOperator operator; public static final String JSON_PROPERTY_TARGET = "target"; - private Object target = new Object(); + private SyntheticsAssertionTargetValue target; public static final String JSON_PROPERTY_TYPE = "type"; private SyntheticsAssertionBodyHashType type; @@ -42,12 +42,14 @@ public SyntheticsAssertionBodyHashTarget() {} public SyntheticsAssertionBodyHashTarget( @JsonProperty(required = true, value = JSON_PROPERTY_OPERATOR) SyntheticsAssertionBodyHashOperator operator, - @JsonProperty(required = true, value = JSON_PROPERTY_TARGET) Object target, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET) + SyntheticsAssertionTargetValue target, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) SyntheticsAssertionBodyHashType type) { this.operator = operator; this.unparsed |= !operator.isValid(); this.target = target; + this.unparsed |= target.unparsed; this.type = type; this.unparsed |= !type.isValid(); } @@ -76,23 +78,24 @@ public void setOperator(SyntheticsAssertionBodyHashOperator operator) { this.operator = operator; } - public SyntheticsAssertionBodyHashTarget target(Object target) { + public SyntheticsAssertionBodyHashTarget target(SyntheticsAssertionTargetValue target) { this.target = target; + this.unparsed |= target.unparsed; return this; } /** - * Value used by the operator. + * Value used by the operator in assertions. Can be either a number or string. * * @return target */ @JsonProperty(JSON_PROPERTY_TARGET) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public Object getTarget() { + public SyntheticsAssertionTargetValue getTarget() { return target; } - public void setTarget(Object target) { + public void setTarget(SyntheticsAssertionTargetValue target) { this.target = target; } diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionJSONPathTargetTarget.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionJSONPathTargetTarget.java index b6a027ffd78..d69a42141fa 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionJSONPathTargetTarget.java +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionJSONPathTargetTarget.java @@ -37,7 +37,7 @@ public class SyntheticsAssertionJSONPathTargetTarget { private String operator; public static final String JSON_PROPERTY_TARGET_VALUE = "targetValue"; - private Object targetValue = null; + private SyntheticsAssertionTargetValue targetValue; public SyntheticsAssertionJSONPathTargetTarget elementsOperator(String elementsOperator) { this.elementsOperator = elementsOperator; @@ -105,24 +105,26 @@ public void setOperator(String operator) { this.operator = operator; } - public SyntheticsAssertionJSONPathTargetTarget targetValue(Object targetValue) { + public SyntheticsAssertionJSONPathTargetTarget targetValue( + SyntheticsAssertionTargetValue targetValue) { this.targetValue = targetValue; + this.unparsed |= targetValue.unparsed; return this; } /** - * The path target value to compare to. + * Value used by the operator in assertions. Can be either a number or string. * * @return targetValue */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TARGET_VALUE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Object getTargetValue() { + public SyntheticsAssertionTargetValue getTargetValue() { return targetValue; } - public void setTargetValue(Object targetValue) { + public void setTargetValue(SyntheticsAssertionTargetValue targetValue) { this.targetValue = targetValue; } diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTarget.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTarget.java index 625339e65a6..f8494f066e3 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTarget.java +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTarget.java @@ -36,7 +36,7 @@ public class SyntheticsAssertionTarget { private String property; public static final String JSON_PROPERTY_TARGET = "target"; - private Object target = new Object(); + private SyntheticsAssertionTargetValue target; public static final String JSON_PROPERTY_TIMINGS_SCOPE = "timingsScope"; private SyntheticsAssertionTimingsScope timingsScope; @@ -50,11 +50,13 @@ public SyntheticsAssertionTarget() {} public SyntheticsAssertionTarget( @JsonProperty(required = true, value = JSON_PROPERTY_OPERATOR) SyntheticsAssertionOperator operator, - @JsonProperty(required = true, value = JSON_PROPERTY_TARGET) Object target, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET) + SyntheticsAssertionTargetValue target, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) SyntheticsAssertionType type) { this.operator = operator; this.unparsed |= !operator.isValid(); this.target = target; + this.unparsed |= target.unparsed; this.type = type; this.unparsed |= !type.isValid(); } @@ -104,23 +106,24 @@ public void setProperty(String property) { this.property = property; } - public SyntheticsAssertionTarget target(Object target) { + public SyntheticsAssertionTarget target(SyntheticsAssertionTargetValue target) { this.target = target; + this.unparsed |= target.unparsed; return this; } /** - * Value used by the operator. + * Value used by the operator in assertions. Can be either a number or string. * * @return target */ @JsonProperty(JSON_PROPERTY_TARGET) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public Object getTarget() { + public SyntheticsAssertionTargetValue getTarget() { return target; } - public void setTarget(Object target) { + public void setTarget(SyntheticsAssertionTargetValue target) { this.target = target; } diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTargetValue.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTargetValue.java new file mode 100644 index 00000000000..69250f1e662 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionTargetValue.java @@ -0,0 +1,276 @@ +/* + * 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. + */ + +package com.datadog.api.client.v1.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = SyntheticsAssertionTargetValue.SyntheticsAssertionTargetValueDeserializer.class) +@JsonSerialize( + using = SyntheticsAssertionTargetValue.SyntheticsAssertionTargetValueSerializer.class) +public class SyntheticsAssertionTargetValue extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(SyntheticsAssertionTargetValue.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class SyntheticsAssertionTargetValueSerializer + extends StdSerializer { + public SyntheticsAssertionTargetValueSerializer(Class t) { + super(t); + } + + public SyntheticsAssertionTargetValueSerializer() { + this(null); + } + + @Override + public void serialize( + SyntheticsAssertionTargetValue value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class SyntheticsAssertionTargetValueDeserializer + extends StdDeserializer { + public SyntheticsAssertionTargetValueDeserializer() { + this(SyntheticsAssertionTargetValue.class); + } + + public SyntheticsAssertionTargetValueDeserializer(Class vc) { + super(vc); + } + + @Override + public SyntheticsAssertionTargetValue deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Double + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (Double.class.equals(Integer.class) + || Double.class.equals(Long.class) + || Double.class.equals(Float.class) + || Double.class.equals(Double.class) + || Double.class.equals(Boolean.class) + || Double.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((Double.class.equals(Integer.class) || Double.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((Double.class.equals(Float.class) || Double.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (Double.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (Double.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(Double.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'Double'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Double'", e); + } + + // deserialize String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + SyntheticsAssertionTargetValue ret = new SyntheticsAssertionTargetValue(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public SyntheticsAssertionTargetValue getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "SyntheticsAssertionTargetValue cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public SyntheticsAssertionTargetValue() { + super("oneOf", Boolean.FALSE); + } + + public SyntheticsAssertionTargetValue(Double o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SyntheticsAssertionTargetValue(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Double", new GenericType() {}); + schemas.put("String", new GenericType() {}); + JSON.registerDescendants( + SyntheticsAssertionTargetValue.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return SyntheticsAssertionTargetValue.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: Double, String + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Double.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException("Invalid instance type. Must be Double, String"); + } + + /** + * Get the actual instance, which can be the following: Double, String + * + * @return The actual instance (Double, String) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Double`. If the actual instance is not `Double`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `Double` + * @throws ClassCastException if the instance is not `Double` + */ + public Double getDouble() throws ClassCastException { + return (Double) super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionXPathTargetTarget.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionXPathTargetTarget.java index f3a802754da..db708ce5a2b 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionXPathTargetTarget.java +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAssertionXPathTargetTarget.java @@ -30,7 +30,7 @@ public class SyntheticsAssertionXPathTargetTarget { private String operator; public static final String JSON_PROPERTY_TARGET_VALUE = "targetValue"; - private Object targetValue = null; + private SyntheticsAssertionTargetValue targetValue; public static final String JSON_PROPERTY_X_PATH = "xPath"; private String xPath; @@ -56,24 +56,26 @@ public void setOperator(String operator) { this.operator = operator; } - public SyntheticsAssertionXPathTargetTarget targetValue(Object targetValue) { + public SyntheticsAssertionXPathTargetTarget targetValue( + SyntheticsAssertionTargetValue targetValue) { this.targetValue = targetValue; + this.unparsed |= targetValue.unparsed; return this; } /** - * The path target value to compare to. + * Value used by the operator in assertions. Can be either a number or string. * * @return targetValue */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TARGET_VALUE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Object getTargetValue() { + public SyntheticsAssertionTargetValue getTargetValue() { return targetValue; } - public void setTargetValue(Object targetValue) { + public void setTargetValue(SyntheticsAssertionTargetValue targetValue) { this.targetValue = targetValue; }