Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
job = Job(self, job_uri, 'POST', uri)
if wait_for_completion:
return job.wait_for_completion(operation_timeout)
else:
return job
elif result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
return self.post(uri, body, logon_required)
elif reason == 1:
# Login user's authentication is fine; this is an
# authorization issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg),
HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
finally:
if wait_for_completion:
stats_total.end()
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
self.delete(uri, logon_required)
return
elif reason == 1:
# Login user's authentication is fine; this is an authorization
# issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg), HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
return self.get(uri, logon_required)
elif reason == 1:
# Login user's authentication is fine; this is an authorization
# issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg), HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
content=result.content)
if result.status_code in (200, 204):
return
elif result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
self.delete(uri, logon_required)
return
elif reason == 1:
# Login user's authentication is fine; this is an authorization
# issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg), HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
elif result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
return self.post(uri, body, logon_required)
elif reason == 1:
# Login user's authentication is fine; this is an
# authorization issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg),
HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
finally:
if wait_for_completion:
stats_total.end()
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
return self.post(uri, body, logon_required)
elif reason == 1:
# Login user's authentication is fine; this is an
# authorization issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg),
HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
finally:
if wait_for_completion:
stats_total.end()
return _result_object(result)
elif result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
return self.get(uri, logon_required)
elif reason == 1:
# Login user's authentication is fine; this is an authorization
# issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg), HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)
if not error_result_obj:
message = None
elif 'message' in error_result_obj:
message = error_result_obj['message']
elif 'error' in error_result_obj:
message = error_result_obj['error']
else:
message = None
error_obj = {
'http-status': op_status_code,
'reason': job_result_obj['job-reason-code'],
'message': message,
'request-method': self.op_method,
'request-uri': self.op_uri,
}
raise HTTPError(error_obj)
else:
op_result_obj = None
return job_status, op_result_obj
elif result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry
self._do_logon()
self.delete(uri, logon_required)
return
elif reason == 1:
# Login user's authentication is fine; this is an authorization
# issue, so we don't raise ServerAuthError.
raise HTTPError(result_object)
else:
msg = result_object.get('message', None)
raise ServerAuthError("HTTP authentication failed: {}".
format(msg), HTTPError(result_object))
else:
result_object = _result_object(result)
raise HTTPError(result_object)