Skip to content

Commit

Permalink
A new option will force or not the json rendering of the response.
Browse files Browse the repository at this point in the history
  • Loading branch information
koalalorenzo committed Oct 19, 2014
1 parent ad21106 commit 67da058
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion digitalocean/Metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, *args, **kwargs):
super(Metadata, self).__init__(*args, **kwargs)
self.end_point = "http://169.254.169.254/metadata/v1"

def get_data(self, url, headers=dict(), params=dict()):
def get_data(self, url, headers=dict(), params=dict(), render_json=True):
"""
Customized version of get_data to directly get the data without
using the authentication method.
Expand All @@ -28,6 +28,9 @@ def get_data(self, url, headers=dict(), params=dict()):
url = urljoin(self.end_point, url)

response = requests.get(url, headers=headers, params=params)

if render_json:
return response.json()
return response.content

def load(self):
Expand Down

0 comments on commit 67da058

Please sign in to comment.