Skip to content
Closed
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
14 changes: 13 additions & 1 deletion src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,19 @@ def todict(obj, post_processor=None):
# azure-core provided new function `attribute_list` to list all attribute names
# so that we don't need to use raw __dict__ directly
if getattr(obj, "_is_model", False):
result = {to_camel_case(attr): todict(getattr(obj, attr), post_processor)
_HYBRID_MODEL_COMPATIBLE_MAP: dict[str, str] = {
"keys_property": "keys",
"values_property": "values",
"items_property": "items",
"get_property": "get",
"pop_property": "pop",
"update_property": "update",
"clear_property": "clear",
"popitem_property": "popitem",
"copy_property": "copy",
"setdefault_property": "setdefault",
}
result = {to_camel_case(_HYBRID_MODEL_COMPATIBLE_MAP.get(attr) or attr): todict(getattr(obj, attr), post_processor)
for attr in attribute_list(obj) if hasattr(obj, attr)}
return post_processor(obj, result) if post_processor else result
if hasattr(obj, '_asdict'):
Expand Down
Loading