Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
headers["X-Session-Key"] = self.session_key
params = {}
if not url_override:
if self.filters:
params = self.filters
if add_params:
params.update(add_params)
req = getattr(self.http_session, verb)(
url_override or self.url, headers=headers, verify=self.ssl_verify,
params=params, json=data
)
if req.status_code == 204 and verb == "post":
raise AllocationError(req)
if verb == "delete":
if req.ok:
return True
else:
raise RequestError(req)
elif req.ok:
try:
return req.json()
except json.JSONDecodeError:
raise ContentError(req)
else:
raise RequestError(req)
def __init__(self, message):
req = message
message = "The requested allocation could not be fulfilled."
super(AllocationError, self).__init__(message)
self.req = req
self.request_body = req.request.body
self.base = req.url
self.error = message