Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Commit

Permalink
"Handle" fetching the resource of a volume action
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Oct 5, 2016
1 parent 0685301 commit 6ffec56
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doapi/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ def fetch_resource(self):
"""
Fetch & return the resource that the action operated on, or `None` if
the resource no longer exists (specifically, if the API returns a 404)
or no resource is given (specifically, if the `resource_id` field is
`None`, which is the case for actions on volumes)
:rtype: `Droplet`, `Image`, `FloatingIP`, or `None`
:raises ValueError: if the action has an unknown ``resource_type``
(This indicates a deficiency in the library; please report it!)
:raises DOAPIError: if the API endpoint replies with a non-404 error
"""
if self.get("resource_id") is None:
return None
try:
if self.resource_type == "droplet":
return self.doapi_manager.fetch_droplet(self.resource_id)
Expand Down

0 comments on commit 6ffec56

Please sign in to comment.