I recently started looking into SDK for Azure and can't figure out why every single method (tested by me) returns an object rather then something more 'human' friendly i.e. list or dictionary.
i.e.:
list(compute_client.virtual_machines.list_all())
[<azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93c190>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93c750>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93cad0>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93ced0>]
What is a benefit of returning objects which seem to be awkward to interact with i.e. I need to lookup every single method to find the return values and so on to process a list and then to build a dictionary it seems as more work then needed.
I have found this method in one of the Microsoft blogs / githubs:
def print_item(group):
"""Print a ResourceGroup instance."""
print("\tName: {}".format(group.name))
print("\tId: {}".format(group.id))
print("\tLocation: {}".format(group.location))
print("\tTags: {}".format(group.tags))
print_properties(group.properties)
This seems so inefficient IMO to be able to print a return value of another method.
Can some one advise why an "object list" is better then a "list" why not to return something like json.