Skip to content

Instantly share code, notes, and snippets.

@msehnout
Created March 20, 2020 19:20
Show Gist options
  • Save msehnout/3bfcf077d57d70afccb282a9dcad12cd to your computer and use it in GitHub Desktop.
Save msehnout/3bfcf077d57d70afccb282a9dcad12cd to your computer and use it in GitHub Desktop.
import requests
from requests_kerberos import HTTPKerberosAuth
class Response:
def __init__(self, data, id, status):
self.data = data
self.id = id
self.status = status
class Client:
def __init__(self, cachito_api_url):
self._cachito_api_url = cachito_api_url
def requests_all_data(self):
req = requests.get(f"{self._cachito_api_url}requests")
req.raise_for_status()
return Response(req.json(), None, req.status_code)
def request_data(self, request_id):
req = requests.get(f"{self._cachito_api_url}requests/{request_id}")
return Response(req.json(), request_id, req.status_code)
def create_new_request(self, **kwargs):
resp = requests.post(f"{self._cachito_api_url}requests", auth=HTTPKerberosAuth(),
headers={"Content-Type": "application/json"}, json=kwargs)
resp.raise_for_status()
return Response(resp.json(), resp.json()["id"], resp.status_code)
def download_output(self):
pass
def get_response_code(self):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment