Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------

Expand Down
5 changes: 1 addition & 4 deletions examples/v2/reference-tables/UpsertRows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
],
}
4 changes: 4 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -5593,6 +5596,7 @@
"BatchUpsertRowsRequestArray",
"BatchUpsertRowsRequestData",
"BatchUpsertRowsRequestDataAttributes",
"BatchUpsertRowsRequestDataAttributesValue",
"BillConfig",
"BillingDimensionsMappingBodyItem",
"BillingDimensionsMappingBodyItemAttributes",
Expand Down
6 changes: 3 additions & 3 deletions tests/v2/features/reference_tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ 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

@generated @skip @team:DataDog/redapl-experiences
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

@generated @skip @team:DataDog/redapl-experiences
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