Skip to content

Commit

Permalink
Action object "migrated" to the new base api class.
Browse files Browse the repository at this point in the history
  • Loading branch information
koalalorenzo committed Aug 11, 2014
1 parent 2803aec commit c4da2d7
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions digitalocean/Action.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import requests
from .baseapi import BaseAPI

class Action(object):
class Action(BaseAPI):
def __init__(self, action_id=""):
super(Action, self).__init__()
self.id = action_id
self.token = None
self.status = None
Expand All @@ -12,22 +13,8 @@ def __init__(self, action_id=""):
self.resource_type = None
self.region = None

def __call_api(self, path, params=dict()):
payload = {}
headers = {'Authorization':'Bearer ' + self.token}
payload.update(params)
r = requests.get("https://api.digitalocean.com/v2/actions/%s" % self.id,
headers=headers,
params=payload)
data = r.json()
self.call_response = data
if r.status_code != requests.codes.ok:
msg = [data[m] for m in ("id", "message") if m in data][1]
raise Exception(msg)
return data

def load(self):
action = self.__call_api('')
action = self.__get_data("https://api.digitalocean.com/v2/actions/%s" % self.id)
if action:
action = action[u'action']
self.id = action[u'id']
Expand Down

0 comments on commit c4da2d7

Please sign in to comment.