diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a4628b43a7..e14e4a498b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -7075,19 +7075,27 @@ components: BatchUpsertRowsRequestDataAttributes: description: Attributes containing row data values for row creation or update operations. + example: + values: {} properties: values: additionalProperties: - x-required-field: true - description: Key-value pairs representing row data, where keys are field - names from the schema. - example: - example_key_value: primary_key_value - name: row_name + $ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributesValue' + description: Key-value pairs representing row data, where keys are schema + field names and values match the corresponding column types. type: object required: - values type: object + BatchUpsertRowsRequestDataAttributesValue: + description: Types allowed for Reference Table row values. + oneOf: + - example: row_name + type: string + - example: 25 + format: int32 + maximum: 2147483647 + type: integer BillConfig: description: Bill config. properties: @@ -79331,6 +79339,18 @@ paths: requestBody: content: application/json: + examples: + happy_path: + summary: Upsert a row with mixed string and int values + value: + data: + - attributes: + values: + age: 25 + example_key_value: primary_key_value + name: row_name + id: primary_key_value + type: row schema: $ref: '#/components/schemas/BatchUpsertRowsRequestArray' required: true diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 3435c17c29..a318bba921 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -2622,6 +2622,13 @@ datadog\_api\_client.v2.model.batch\_upsert\_rows\_request\_data\_attributes mod :members: :show-inheritance: +datadog\_api\_client.v2.model.batch\_upsert\_rows\_request\_data\_attributes\_value module +------------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes_value + :members: + :show-inheritance: + datadog\_api\_client.v2.model.bill\_config module ------------------------------------------------- diff --git a/examples/v2/reference-tables/UpsertRows.py b/examples/v2/reference-tables/UpsertRows.py index b6f1fa9616..26eec492b1 100644 --- a/examples/v2/reference-tables/UpsertRows.py +++ b/examples/v2/reference-tables/UpsertRows.py @@ -13,10 +13,7 @@ data=[ BatchUpsertRowsRequestData( attributes=BatchUpsertRowsRequestDataAttributes( - values=dict( - example_key_value="primary_key_value", - name="row_name", - ), + values=dict(), ), id="primary_key_value", type=TableRowResourceDataType.ROW, diff --git a/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes.py b/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes.py index c1ea9d9a6a..d78dd8a745 100644 --- a/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes.py +++ b/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes.py @@ -3,50 +3,41 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Any, Dict +from typing import Dict, Union, TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, cached_property, - date, - datetime, - none_type, - UUID, ) +if TYPE_CHECKING: + from datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes_value import ( + BatchUpsertRowsRequestDataAttributesValue, + ) + + class BatchUpsertRowsRequestDataAttributes(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes_value import ( + BatchUpsertRowsRequestDataAttributesValue, + ) + return { - "values": ( - { - str: ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - UUID, - none_type, - ) - }, - ), + "values": ({str: (BatchUpsertRowsRequestDataAttributesValue,)},), } attribute_map = { "values": "values", } - def __init__(self_, values: Dict[str, Any], **kwargs): + def __init__(self_, values: Dict[str, Union[BatchUpsertRowsRequestDataAttributesValue, str, int]], **kwargs): """ Attributes containing row data values for row creation or update operations. - :param values: Key-value pairs representing row data, where keys are field names from the schema. - :type values: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)} + :param values: Key-value pairs representing row data, where keys are schema field names and values match the corresponding column types. + :type values: {str: (BatchUpsertRowsRequestDataAttributesValue,)} """ super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes_value.py b/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes_value.py new file mode 100644 index 0000000000..c695ef792c --- /dev/null +++ b/src/datadog_api_client/v2/model/batch_upsert_rows_request_data_attributes_value.py @@ -0,0 +1,34 @@ +# 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 ( + ModelComposed, + cached_property, +) + + +class BatchUpsertRowsRequestDataAttributesValue(ModelComposed): + def __init__(self, **kwargs): + """ + Types allowed for Reference Table row values. + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + "oneOf": [ + str, + int, + ], + } diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index b56279b372..5ce54caf0b 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -501,6 +501,9 @@ from datadog_api_client.v2.model.batch_upsert_rows_request_array import BatchUpsertRowsRequestArray from datadog_api_client.v2.model.batch_upsert_rows_request_data import BatchUpsertRowsRequestData from datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes import BatchUpsertRowsRequestDataAttributes +from datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes_value import ( + BatchUpsertRowsRequestDataAttributesValue, +) from datadog_api_client.v2.model.bill_config import BillConfig from datadog_api_client.v2.model.billing_dimensions_mapping_body_item import BillingDimensionsMappingBodyItem from datadog_api_client.v2.model.billing_dimensions_mapping_body_item_attributes import ( @@ -5593,6 +5596,7 @@ "BatchUpsertRowsRequestArray", "BatchUpsertRowsRequestData", "BatchUpsertRowsRequestDataAttributes", + "BatchUpsertRowsRequestDataAttributesValue", "BillConfig", "BillingDimensionsMappingBodyItem", "BillingDimensionsMappingBodyItemAttributes", diff --git a/tests/v2/features/reference_tables.feature b/tests/v2/features/reference_tables.feature index 45a2861c15..230be9e8f4 100644 --- a/tests/v2/features/reference_tables.feature +++ b/tests/v2/features/reference_tables.feature @@ -148,7 +148,7 @@ Feature: Reference Tables Scenario: Upsert rows returns "Bad Request" response Given new "UpsertRows" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]} When the request is sent Then the response status is 400 Bad Request @@ -156,7 +156,7 @@ Feature: Reference Tables Scenario: Upsert rows returns "Not Found" response Given new "UpsertRows" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]} When the request is sent Then the response status is 404 Not Found @@ -164,6 +164,6 @@ Feature: Reference Tables Scenario: Upsert rows returns "Rows created or updated successfully" response Given new "UpsertRows" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]} When the request is sent Then the response status is 200 Rows created or updated successfully