Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
params=params,
method=method,
data=data,
doseq=doseq,
query=query,
retried=True,
**options
)
if self.access_token:
self.log.warning(
"In order to enable automated refreshing of your access token, please "
"provide a client ID, client secret and refresh token in addition to the "
"access token."
)
raise
except HubspotError as exception:
if try_count > num_retries:
logging.warning("Too many retries for {}".format(url))
raise
# Don't retry errors from 300 to 499
if exception.result and 300 <= exception.result.status < 500:
raise
self._prepare_request_retry(method, url, headers, data)
self.log.warning(
"HubspotError {} calling {}, retrying".format(exception, url)
)
# exponential back off
# wait 0 seconds, 1 second, 3 seconds, 7 seconds, 15 seconds, etc
time.sleep((pow(2, try_count - 1) - 1) * self.sleep_multiplier)
return result
# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
"""most 40X results and 501 results"""
class HubspotNotFound(HubspotError):
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
"""most 500 errors"""
class HubspotRateLimited(HubspotError):
"""exception for when we're rate limited"""
unicode_data[key] = val
else:
unicode_data[key] = str(type(val))
return unicode_data
class HubspotBadConfig(Exception):
"""misconfigured api_key and/or access_token credentials client"""
class HubspotNoConfig(Exception):
"""no api_key or access_token credentials were passed to the client"""
# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
"""most 40X results and 501 results"""
class HubspotNotFound(HubspotError):
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
class HubspotNoConfig(Exception):
"""no api_key or access_token credentials were passed to the client"""
# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
"""most 40X results and 501 results"""
class HubspotNotFound(HubspotError):
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
"""most 500 errors"""
class HubspotRateLimited(HubspotError):
"""most 40X results and 501 results"""
class HubspotNotFound(HubspotError):
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
"""most 500 errors"""
class HubspotRateLimited(HubspotError):
"""exception for when we're rate limited"""
def __init__(self, result, request, err=None):
super(HubspotError, self).__init__(result and result.reason or "Unknown Reason")
if result is None:
self.result = EmptyResult()
else:
self.result = result
if request is None:
request = {}
self.request = request
self.err = err
class HubspotBadConfig(Exception):
"""misconfigured api_key and/or access_token credentials client"""
class HubspotNoConfig(Exception):
"""no api_key or access_token credentials were passed to the client"""
# Create more specific error cases, to make filtering errors easier
class HubspotBadRequest(HubspotError):
"""most 40X results and 501 results"""
class HubspotNotFound(HubspotError):
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
def delete_setting(self, name: str, **options):
"""Deletes a specific setting by emptying out its value."""
params = {}
if name:
params["name"] = name
else:
raise HubspotError("Setting name required.", "settings")
return self._call("settings", params=params, method="DELETE", **options)
"""404 and 410 results"""
class HubspotTimeout(HubspotError):
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
"""most 500 errors"""
class HubspotRateLimited(HubspotError):
"""exception for when we're rate limited"""
"""socket timeouts, sslerror, and 504"""
class HubspotUnauthorized(HubspotError):
"""401 Unauthorized errors"""
class HubspotConflict(HubspotError):
"""409 conflict errors"""
class HubspotServerError(HubspotError):
"""most 500 errors"""
class HubspotRateLimited(HubspotError):
"""exception for when we're rate limited"""