Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

CapacityList.to_dict does not work #102

Closed
ctreatma opened this issue Jun 28, 2024 · 0 comments
Closed

CapacityList.to_dict does not work #102

ctreatma opened this issue Jun 28, 2024 · 0 comments

Comments

@ctreatma
Copy link
Contributor

ctreatma commented Jun 28, 2024

The CapacityList.to_dict function does not work because it attempts to call to_dict on each Capacity in the CapacityList, but Capacity is already a dict. This probably requires a fix in openapi-generator, but we may be able to fix it with custom templates. If we can fix it with custom templates we should contribute that template change back to openapi-generator as well.

From equinix/ansible-collection-equinix#194 (comment)

The code is failing with the following error due to a bug in the SDK:

File "/tmp/ansible_equinix.cloud.metal_metro_capacity_info_payload_csk2ijq1/ansible_equinix.cloud.metal_metro_capacity_info_payload.zip/ansible_collections/equinix/cloud/plugins/module_utils/metal/metal_api.py", line 447, in populate_ids_from_hrefs return_dict = response.to_dict()
File "/home/pcernada/.local/lib/python3.10/site-packages/equinix_metal/models/capacity_list.py", line 79, in to_dict _field_dict[_key] = self.capacity[_key].to_dict() AttributeError: 'dict' object has no attribute 'to_dict'

This error occurs because the to_dict method is being called on a dictionary object, which does not have this method. The capacity field in the capacity_list model is expected to contain objects with a to_dict method, but it currently contains plain dictionaries instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant