diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-09-18 23:37:17 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-09-18 23:38:27 -0700 |
commit | 02daeaf2652383985bc4d31170d8180f58ce1b18 (patch) | |
tree | 722c3ce7b193bc125d0c6bf2748abe5982fbbde8 /python_openapi_client/fatcat_openapi_client/rest.py | |
parent | bf9ec36fd482940a5bbe63cb13d2d6518b93a27d (diff) | |
download | fatcat-02daeaf2652383985bc4d31170d8180f58ce1b18.tar.gz fatcat-02daeaf2652383985bc4d31170d8180f58ce1b18.zip |
python codegen with new openapi-generator tool
Diffstat (limited to 'python_openapi_client/fatcat_openapi_client/rest.py')
-rw-r--r-- | python_openapi_client/fatcat_openapi_client/rest.py | 46 |
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 |