Skip to content

Commit

Permalink
Removed from SSHKey class the __call_api method: obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
koalalorenzo committed Aug 11, 2014
1 parent 5553257 commit 66d5af4
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions digitalocean/SSHKey.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,6 @@ def __init__(self, token="", *args, **kwargs):
for attr in kwargs.keys():
setattr(self,attr,kwargs[attr])

def __call_api(self, type, params=dict()):
headers = {'Authorization':'Bearer ' + self.token}
if type == 'POST':
headers['content-type'] = 'application/json'
r = requests.post("https://api.digitalocean.com/v2/account/keys/",
headers=headers,
params=params)
elif type == 'PUT':
headers['content-type'] = 'application/json'
r = requests.put("https://api.digitalocean.com/v2/account/keys/%s" %
self.id,
headers=headers,
params=params)
elif type == 'DELETE':
headers['content-type'] = 'application/x-www-form-urlencoded'
r = requests.delete("https://api.digitalocean.com/v2/account/keys/%s" %
self.id,
headers=headers,
params=params)
else:
r = requests.get("https://api.digitalocean.com/v2/account/keys/%s" %
self.id,
headers=headers,
params=params)

# A successful delete returns "204 No Content"
if r.status_code != 204:
data = r.json()
self.call_response = data
if r.status_code not in [requests.codes.ok, 202, 201]:
msg = [data[m] for m in ("id", "message") if m in data][1]
raise Exception(msg)

return data

def load(self):
data = self.get_data(
"account/keys/%s" % self.id,
Expand Down

0 comments on commit 66d5af4

Please sign in to comment.