Skip to content
Snippets Groups Projects

CLI tool to upload files and start imports

Merged Bastien Abadie requested to merge cli into master
All threads resolved!
1 file
+ 17
1
Compare changes
  • Side-by-side
  • Inline
+ 17
1
@@ -25,17 +25,33 @@ class ArkindexAPI(object):
response.raise_for_status()
return response.json()
def post(self, endpoint, params=None, json=None, requires_auth=False):
def post(self, endpoint, params=None, json=None, files=None, requires_auth=False):
response = requests.post(
urljoin(self.base_url, endpoint),
params=params,
json=json,
files=files,
auth=self._get_auth(requires_auth),
verify=self.verify_ssl,
)
if response.status_code == 400:
try:
self.bad_request_handler(response.json())
except ArkindexAPIError:
# Ignore everything but Arkindex exceptions from the custom handler
raise
except:
pass
response.raise_for_status()
return response.json()
def bad_request_handler(self, json):
if isinstance(json, list):
raise ArkindexAPIError(' - '.join(json))
elif isinstance(json, dict) and 'detail' in json:
raise ArkindexAPIError(json['detail'])
raise ArkindexAPIError(json)
def login(self, email, password):
'''
Login on an Arkindex server with email+password
Loading