forked from gooddata/gooddata-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod_set_attribute.mustache
More file actions
63 lines (59 loc) · 2.39 KB
/
Copy pathmethod_set_attribute.mustache
File metadata and controls
63 lines (59 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def set_attribute(self, name, value):
# this is only used to set properties on self
path_to_item = []
if self._path_to_item:
path_to_item.extend(self._path_to_item)
path_to_item.append(name)
if name in self.openapi_types:
# Widened from upstream: for a composed (oneOf/anyOf) model the
# generator flattens the members' properties into the parent but
# keeps only the last member's type, so the parent alone rejects
# payloads valid for every other member. See composed_union_types.
required_types_mixed = (
composed_union_types(type(self), name) or self.openapi_types[name]
)
elif self.additional_properties_type is None:
raise ApiAttributeError(
"{0} has no attribute '{1}'".format(
type(self).__name__, name),
path_to_item
)
elif self.additional_properties_type is not None:
required_types_mixed = self.additional_properties_type
if get_simple_class(name) != str:
error_msg = type_error_message(
var_name=name,
var_value=name,
valid_classes=(str,),
key_type=True
)
raise ApiTypeError(
error_msg,
path_to_item=path_to_item,
valid_classes=(str,),
key_type=True
)
if self._check_type:
value = validate_and_convert_types(
value, required_types_mixed, path_to_item, self._spec_property_naming,
self._check_type, configuration=self._configuration)
# Widened from upstream for the same reason as required_types_mixed
# above: the flattened parent keeps only the last member's enum.
allowed_values = (
composed_union_allowed_values(type(self), name)
or self.allowed_values.get((name,))
)
if allowed_values:
check_allowed_values(
{(name,): allowed_values},
(name,),
value
)
if (name,) in self.validations:
check_validations(
self.validations,
(name,),
value,
self._configuration
)
self.__dict__['_data_store'][name] = value