added basic python client and a basic commandline tool.

This commit is contained in:
adriant
2014-02-19 17:10:09 +13:00
parent 1b85745680
commit ab1beca360
2 changed files with 82 additions and 0 deletions

30
client/client.py Normal file
View File

@@ -0,0 +1,30 @@
import requests
class Client(object):
def __init__(self, endpoint, **kwargs):
self.endpoint = endpoint
self.auth_token = kwargs.get('token')
def usage(self, tenants):
url = self.endpoint + "usage"
data = {"tenants": tenants}
response = requests.post(url,
headers={"Content-Type": "application/json",
"token": self.auth_token},
data=data)
if response.status_code != 200:
raise AttributeError("Usage cycle failed: " + response.text +
" code: " + str(response.status_code))
def sales_order(self, tenants):
url = self.endpoint + "sales_order"
data = {"tenants": tenants}
response = requests.post(url,
headers={"Content-Type": "application/json",
"token": self.auth_token},
data=data)
if response.status_code != 200:
raise AttributeError("Sales order cycle failed: " + response.text +
" code: " + str(response.status_code))