import hmac
import json
import tornado.httpclient
-import tornado.gen
import urllib.parse
from .misc import Object
if not all((self.url, self.api_key, self.api_secret)):
raise RuntimeError("%s is not configured" % self.__class__.__name__)
- # Create HTTPClient
- self.http_client = tornado.httpclient.AsyncHTTPClient(
- defaults = {
- "User-Agent" : "IPFireWebApp",
- }
- )
-
def _make_signature(self, method, path, body):
# Empty since we only support POST
canonical_query = ""
return h.hexdigest()
- @tornado.gen.coroutine
- def send_request(self, path, **kwargs):
+ async def send_request(self, path, **kwargs):
url = urllib.parse.urljoin(self.url, path)
# Query arguments are all keyword arguments
)
# Send the request
- response = yield self.http_client.fetch(request)
+ response = await self.backend.http_client.fetch(request)
# Decode the JSON response
- d = json.loads(response.body.decode())
-
- raise tornado.gen.Return(d)
+ return json.loads(response.body.decode())