You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I couldn't seem to find the Python API for getting storage details which is documented here. Did I overlook it or is it simply not implemented yet?
Hi there! The functionality is available through the CloudManager with manager.get_storage(storage.uuid). There are some other storage examples here. Before using, CloudManager needs be be initialized and there are examples for in in the main Readme.
Could you try this out? Happy to help if you run into any problems with it.
Currently to_dict() function in storage objects is used for creating a JSON object that includes the relevant items for the storage objects in the UpCloud server API. If you want your object as a dictionary, can't you just create it from the object with .__dict__? So for example:
Yes, I could but it seems like it's not very intuitive to have to do that when there's a method called to_dict() which seems like it should do the same thing. This information is also not documented anywhere in the documentation. Might be just me being non-Python expert though.
Yup, it's hard to disagree with you on this. The only excuse is that it's not documented as it's meant as an internal function. We should change it to work as you would expect but as this would be a breaking change, we'll need to wait for the next larger release to do it. Could you create a separate issue for this change (and adding similar to_dict() functionality to other objects as well) or modify the title of this one, so we can track this change better?
Activity
ajmyyra commentedon May 17, 2021
Hi there! The functionality is available through the CloudManager with
manager.get_storage(storage.uuid). There are some other storage examples here. Before using, CloudManager needs be be initialized and there are examples for in in the main Readme.Could you try this out? Happy to help if you run into any problems with it.
aqiank commentedon May 17, 2021
Hi @ajmyyra, when I use
manager.get_storage(storage.uuid).to_dict(), it returns this:{ "tier": "maxiops", "title": "xxx", "size": 16, "zone": "xxx" }But when I use the documented API via
requests, it returns this:{ "storage": { "access": "private", "backup_rule": {}, "backups": { "backup": [] }, "license": 0, "servers": { "server": [ "xxx" ] }, "size": 16, "state": "online", "tier": "maxiops", "title": "xxx", "type": "normal", "uuid": "xxx", "zone": "xxx" } }So it seems like they are not equivalent?
ajmyyra commentedon May 17, 2021
Hi,
As Storage is an object, getting a dict out of it is not that straightforward. Using it on its own should give you a lot more details:
aqiank commentedon May 17, 2021
Hmm is there a reason that those other fields are left out of the
to_dict()output?ajmyyra commentedon May 18, 2021
Currently to_dict() function in storage objects is used for creating a JSON object that includes the relevant items for the storage objects in the UpCloud server API. If you want your object as a dictionary, can't you just create it from the object with
.__dict__? So for example:aqiank commentedon May 18, 2021
Yes, I could but it seems like it's not very intuitive to have to do that when there's a method called
to_dict()which seems like it should do the same thing. This information is also not documented anywhere in the documentation. Might be just me being non-Python expert though.ajmyyra commentedon May 18, 2021
Yup, it's hard to disagree with you on this. The only excuse is that it's not documented as it's meant as an internal function. We should change it to work as you would expect but as this would be a breaking change, we'll need to wait for the next larger release to do it. Could you create a separate issue for this change (and adding similar to_dict() functionality to other objects as well) or modify the title of this one, so we can track this change better?
[-]Missing function for getting storage details[/-][+]Include complete data in to_dict() methods[/+]aqiank commentedon May 19, 2021
Sure, I've renamed the title. Let me know if it's a suitable title and thanks!
ajmyyra commentedon May 19, 2021
It is, thank you! Hopefully we can get back to this in the near future.