Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

Unable to rebuild model from dict if several flattening layered #194

Closed lmazuel closed 4 years ago

lmazuel commented 4 years ago
from datetime import timedelta

body = {}
body['kind'] = 'LongTerm'
body['location'] = 'westus'  # str
body['tags'] = {}  # dictionary
body.setdefault('sku', {})['name'] = 'sku_name'  # str
body.setdefault('sku', {})['capacity'] = 42  # number
body['time_series_id_properties'] = [{"name": "deviceId", "type": "String"}, {"name": "deviceId2", "type": "String"}]  # [TimeSeriesIdProperty]
body['storage_configuration'] = {"account_name": 'storage_account_name', "management_key": 'storage_management_key'}  # LongTermStorageConfigurationInput
body['data_retention'] = timedelta(days=1)

from azure.mgmt.timeseriesinsights.models import LongTermEnvironmentCreateOrUpdateParameters

LongTermEnvironmentCreateOrUpdateParameters.from_dict(body)
jiasli commented 4 years ago

Thanks @lmazuel. Linking to the PR https://github.com/Azure/msrest-for-python/pull/193 that makes rest_key_extractor and rest_key_case_insensitive_extractor safer.

lmazuel commented 4 years ago

Fixed by https://github.com/Azure/msrest-for-python/pull/198