Commit b31051d6 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Syntax check and debug

parent b4368e33
......@@ -31,45 +31,18 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from kamaki.clients.commissioning import Callpoint, CallError
from kamaki.clients.commissioning.utils.debug import debug
from kamaki.clients import Client
from kamaki.clients.quotaholder.api import (
from kamaki.clients.commissioning_client import CommissioningClient
from json import loads as json_loads, dumps as json_dumps
class QuotaholderClient(CommissioningClient):
class CommissioningClient(Callpoint):
api_spec = QuotaholderAPI()
appname = 'quotaholder'
def __init__(self, base_url, token):
super(CommissioningClient, self).__init__()
self._kc = Client(base_url, token)
def do_make_call(self, api_call, data):
_kc = self._kc
gettable = ['list', 'get', 'read']
method = (_kc.get if any(api_call.startswith(x) for x in gettable)
path = api_call
json_data = json_dumps(data)
debug("%s %s\n%s\n<<<\n", method.func_name, path, json_data)
resp = method(path, data=json_data, success=(200, 450, 500))
debug(">>>\nStatus: %s", resp.status_code)
body = resp.text
debug("\n%s\n<<<\n", body[:128] if body else None)
status = int(resp.status_code)
if status == 200:
return json_loads(body)
error = json_loads(body)
except ValueError:
exc = CallError(body, call_error='ValueError')
exc = CallError.from_dict(error)
raise exc
def __init__(self, base_url=None, token=None):
default_url = ''
base_url = base_url if base_url else default_url
super(self.__class__, self).__init__(base_url, token)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment