aboutsummaryrefslogtreecommitdiffstats
path: root/python_openapi_client/fatcat_openapi_client/rest.py
diff options
context:
space:
mode:
Diffstat (limited to 'python_openapi_client/fatcat_openapi_client/rest.py')
-rw-r--r--python_openapi_client/fatcat_openapi_client/rest.py46
1 files changed, 10 insertions, 36 deletions
diff --git a/python_openapi_client/fatcat_openapi_client/rest.py b/python_openapi_client/fatcat_openapi_client/rest.py
index a0eb1187..d049b537 100644
--- a/python_openapi_client/fatcat_openapi_client/rest.py
+++ b/python_openapi_client/fatcat_openapi_client/rest.py
@@ -5,9 +5,9 @@
Fatcat is a scalable, versioned, API-oriented catalog of bibliographic entities and file metadata. # noqa: E501
- OpenAPI spec version: 0.3.1
+ The version of the OpenAPI document: 0.3.1
Contact: webservices@archive.org
- Generated by: https://github.com/swagger-api/swagger-codegen.git
+ Generated by: https://openapi-generator.tech
"""
@@ -23,11 +23,9 @@ import certifi
# python 2 and python 3 compatibility library
import six
from six.moves.urllib.parse import urlencode
+import urllib3
-try:
- import urllib3
-except ImportError:
- raise ImportError('Swagger python client requires urllib3.')
+from fatcat_openapi_client.exceptions import ApiException, ApiValueError
logger = logging.getLogger(__name__)
@@ -76,6 +74,9 @@ class RESTClientObject(object):
if configuration.assert_hostname is not None:
addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
+ if configuration.retries is not None:
+ addition_pool_args['retries'] = configuration.retries
+
if maxsize is None:
if configuration.connection_pool_maxsize is not None:
maxsize = configuration.connection_pool_maxsize
@@ -92,6 +93,7 @@ class RESTClientObject(object):
cert_file=configuration.cert_file,
key_file=configuration.key_file,
proxy_url=configuration.proxy,
+ proxy_headers=configuration.proxy_headers,
**addition_pool_args
)
else:
@@ -131,7 +133,7 @@ class RESTClientObject(object):
'PATCH', 'OPTIONS']
if post_params and body:
- raise ValueError(
+ raise ApiValueError(
"body parameter cannot be used with post_params parameter."
)
@@ -188,7 +190,7 @@ class RESTClientObject(object):
# Pass a `string` parameter directly in the body to support
# other content types than Json when `body` argument is
# provided in serialized form
- elif isinstance(body, str):
+ elif isinstance(body, str) or isinstance(body, bytes):
request_body = body
r = self.pool_manager.request(
method, url,
@@ -293,31 +295,3 @@ class RESTClientObject(object):
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body)
-
-
-class ApiException(Exception):
-
- def __init__(self, status=None, reason=None, http_resp=None):
- if http_resp:
- self.status = http_resp.status
- self.reason = http_resp.reason
- self.body = http_resp.data
- self.headers = http_resp.getheaders()
- else:
- self.status = status
- self.reason = reason
- self.body = None
- self.headers = None
-
- def __str__(self):
- """Custom error messages for exception"""
- error_message = "({0})\n"\
- "Reason: {1}\n".format(self.status, self.reason)
- if self.headers:
- error_message += "HTTP response headers: {0}\n".format(
- self.headers)
-
- if self.body:
- error_message += "HTTP response body: {0}\n".format(self.body)
-
- return error_message