added basic python client and a basic commandline tool.
This commit is contained in:
30
client/client.py
Normal file
30
client/client.py
Normal 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))
|
||||
Reference in New Issue
Block a user