Skip to content

Commit dae960b

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
FIx handling of log aggregation oneOf in Python (#463)
* Fix handling of log aggregate oneOf * Regenerate client from commit b3fffea of spec repo Co-authored-by: Thomas Hervé <[email protected]> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent a1f9560 commit dae960b

20 files changed

+236
-25
lines changed

.apigentools-info

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.4.1.dev8",
7-
"regenerated": "2021-06-03 18:55:49.527271",
8-
"spec_repo_commit": "f5f3f9b"
7+
"regenerated": "2021-06-04 09:04:21.709024",
8+
"spec_repo_commit": "b3fffea"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-03 18:56:14.612629",
13-
"spec_repo_commit": "f5f3f9b"
12+
"regenerated": "2021-06-04 09:04:47.790201",
13+
"spec_repo_commit": "b3fffea"
1414
}
1515
}
16-
}
16+
}

.generator/templates/model_templates/method_init_simple.mustache

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@
5656
valid_classes=(self.__class__,),
5757
)
5858

59+
{{#isArray}}
60+
if not isinstance(value, list):
61+
raise ApiTypeError(
62+
"Invalid non-list arguments=%s passed to %s." % (
63+
args,
64+
self.__class__.__name__,
65+
),
66+
path_to_item=_path_to_item,
67+
valid_classes=(self.__class__,),
68+
)
69+
70+
{{/isArray}}
5971
self._data_store = {}
6072
self._check_type = _check_type
6173
self._spec_property_naming = _spec_property_naming
@@ -71,4 +83,4 @@
7183
),
7284
path_to_item=_path_to_item,
7385
valid_classes=(self.__class__,),
74-
)
86+
)

.generator/templates/model_utils.mustache

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{>partial_header}}
22

3+
import copy
34
from datetime import date, datetime # noqa: F401
45
import inspect
56
import io
@@ -913,7 +914,10 @@ def deserialize_model(model_data, model_class, path_to_item, check_type,
913914
if issubclass(model_class, ModelSimple):
914915
return model_class(model_data, **kw_args)
915916
elif isinstance(model_data, list):
916-
return model_class(*model_data, **kw_args)
917+
if issubclass(model_class, ModelComposed) and allows_single_value_input(model_class):
918+
return model_class(model_data, **kw_args)
919+
else:
920+
return model_class(*model_data, **kw_args)
917921
if isinstance(model_data, dict):
918922
kw_args.update(model_data)
919923
return model_class(**kw_args)
@@ -1364,6 +1368,10 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
13641368
if len(cls._composed_schemas['oneOf']) == 0:
13651369
return None
13661370

1371+
# Buld a configuration that doesn't discard unknown keys for primitive types
1372+
discard_configuration = copy.deepcopy(constant_kwargs["_configuration"])
1373+
discard_configuration.discard_unknown_keys = False
1374+
13671375
oneof_instances = []
13681376
# Iterate over each oneOf schema and determine if the input data
13691377
# matches the oneOf schemas.
@@ -1412,7 +1420,7 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
14121420
constant_kwargs['_path_to_item'],
14131421
constant_kwargs['_spec_property_naming'],
14141422
constant_kwargs['_check_type'],
1415-
configuration=constant_kwargs['_configuration']
1423+
configuration=discard_configuration
14161424
)
14171425
oneof_instances.append(oneof_instance)
14181426
except Exception:

src/datadog_api_client/v1/model/azure_account_list_response.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ def __init__(self, *args, **kwargs):
163163
valid_classes=(self.__class__,),
164164
)
165165

166+
if not isinstance(value, list):
167+
raise ApiTypeError(
168+
"Invalid non-list arguments=%s passed to %s."
169+
% (
170+
args,
171+
self.__class__.__name__,
172+
),
173+
path_to_item=_path_to_item,
174+
valid_classes=(self.__class__,),
175+
)
176+
166177
self._data_store = {}
167178
self._check_type = _check_type
168179
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/gcp_account_list_response.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ def __init__(self, *args, **kwargs):
163163
valid_classes=(self.__class__,),
164164
)
165165

166+
if not isinstance(value, list):
167+
raise ApiTypeError(
168+
"Invalid non-list arguments=%s passed to %s."
169+
% (
170+
args,
171+
self.__class__.__name__,
172+
),
173+
path_to_item=_path_to_item,
174+
valid_classes=(self.__class__,),
175+
)
176+
166177
self._data_store = {}
167178
self._check_type = _check_type
168179
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/http_log.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ def __init__(self, *args, **kwargs):
163163
valid_classes=(self.__class__,),
164164
)
165165

166+
if not isinstance(value, list):
167+
raise ApiTypeError(
168+
"Invalid non-list arguments=%s passed to %s."
169+
% (
170+
args,
171+
self.__class__.__name__,
172+
),
173+
path_to_item=_path_to_item,
174+
valid_classes=(self.__class__,),
175+
)
176+
166177
self._data_store = {}
167178
self._check_type = _check_type
168179
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/logs_pipeline_list.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ def __init__(self, *args, **kwargs):
163163
valid_classes=(self.__class__,),
164164
)
165165

166+
if not isinstance(value, list):
167+
raise ApiTypeError(
168+
"Invalid non-list arguments=%s passed to %s."
169+
% (
170+
args,
171+
self.__class__.__name__,
172+
),
173+
path_to_item=_path_to_item,
174+
valid_classes=(self.__class__,),
175+
)
176+
166177
self._data_store = {}
167178
self._check_type = _check_type
168179
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/monitor_search_count.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ def __init__(self, *args, **kwargs):
156156
valid_classes=(self.__class__,),
157157
)
158158

159+
if not isinstance(value, list):
160+
raise ApiTypeError(
161+
"Invalid non-list arguments=%s passed to %s."
162+
% (
163+
args,
164+
self.__class__.__name__,
165+
),
166+
path_to_item=_path_to_item,
167+
valid_classes=(self.__class__,),
168+
)
169+
159170
self._data_store = {}
160171
self._check_type = _check_type
161172
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/point.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ def __init__(self, *args, **kwargs):
161161
valid_classes=(self.__class__,),
162162
)
163163

164+
if not isinstance(value, list):
165+
raise ApiTypeError(
166+
"Invalid non-list arguments=%s passed to %s."
167+
% (
168+
args,
169+
self.__class__.__name__,
170+
),
171+
path_to_item=_path_to_item,
172+
valid_classes=(self.__class__,),
173+
)
174+
164175
self._data_store = {}
165176
self._check_type = _check_type
166177
self._spec_property_naming = _spec_property_naming

src/datadog_api_client/v1/model/service_checks.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ def __init__(self, *args, **kwargs):
163163
valid_classes=(self.__class__,),
164164
)
165165

166+
if not isinstance(value, list):
167+
raise ApiTypeError(
168+
"Invalid non-list arguments=%s passed to %s."
169+
% (
170+
args,
171+
self.__class__.__name__,
172+
),
173+
path_to_item=_path_to_item,
174+
valid_classes=(self.__class__,),
175+
)
176+
166177
self._data_store = {}
167178
self._check_type = _check_type
168179
self._spec_property_naming = _spec_property_naming

0 commit comments

Comments
 (0)