mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 13:22:46 +00:00
rebuilt
This commit is contained in:
@@ -67,8 +67,8 @@ If you want to run the tests in all the python platforms:
|
||||
```sh
|
||||
$ make test-all
|
||||
[... tox creates a virtualenv for every platform and runs tests inside of each]
|
||||
py27: commands succeeded
|
||||
py34: commands succeeded
|
||||
congratulations :)
|
||||
py27: commands succeeded
|
||||
py34: commands succeeded
|
||||
congratulations :)
|
||||
```
|
||||
|
||||
|
||||
@@ -22,282 +22,282 @@ import random
|
||||
from six import iteritems
|
||||
|
||||
try:
|
||||
# for python3
|
||||
from urllib.parse import quote
|
||||
# for python3
|
||||
from urllib.parse import quote
|
||||
except ImportError:
|
||||
# for python2
|
||||
from urllib import quote
|
||||
# for python2
|
||||
from urllib import quote
|
||||
|
||||
from . import configuration
|
||||
|
||||
class ApiClient(object):
|
||||
"""
|
||||
Generic API client for Swagger client library builds
|
||||
"""
|
||||
Generic API client for Swagger client library builds
|
||||
|
||||
:param host: The base path for the server to call
|
||||
:param header_name: a header to pass when making calls to the API
|
||||
:param header_value: a header value to pass when making calls to the API
|
||||
"""
|
||||
def __init__(self, host=configuration.host, header_name=None, header_value=None):
|
||||
self.default_headers = {}
|
||||
if header_name is not None:
|
||||
self.default_headers[header_name] = header_value
|
||||
self.host = host
|
||||
self.cookie = None
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'Python-Swagger'
|
||||
:param host: The base path for the server to call
|
||||
:param header_name: a header to pass when making calls to the API
|
||||
:param header_value: a header value to pass when making calls to the API
|
||||
"""
|
||||
def __init__(self, host=configuration.host, header_name=None, header_value=None):
|
||||
self.default_headers = {}
|
||||
if header_name is not None:
|
||||
self.default_headers[header_name] = header_value
|
||||
self.host = host
|
||||
self.cookie = None
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'Python-Swagger'
|
||||
|
||||
@property
|
||||
def user_agent(self):
|
||||
return self.default_headers['User-Agent']
|
||||
@property
|
||||
def user_agent(self):
|
||||
return self.default_headers['User-Agent']
|
||||
|
||||
@user_agent.setter
|
||||
def user_agent(self, value):
|
||||
self.default_headers['User-Agent'] = value
|
||||
@user_agent.setter
|
||||
def user_agent(self, value):
|
||||
self.default_headers['User-Agent'] = value
|
||||
|
||||
def set_default_header(self, header_name, header_value):
|
||||
self.default_headers[header_name] = header_value
|
||||
def set_default_header(self, header_name, header_value):
|
||||
self.default_headers[header_name] = header_value
|
||||
|
||||
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None, response=None, auth_settings=None):
|
||||
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None, response=None, auth_settings=None):
|
||||
|
||||
# headers parameters
|
||||
header_params = header_params or {}
|
||||
header_params.update(self.default_headers)
|
||||
if self.cookie:
|
||||
header_params['Cookie'] = self.cookie
|
||||
if header_params:
|
||||
header_params = self.sanitize_for_serialization(header_params)
|
||||
# headers parameters
|
||||
header_params = header_params or {}
|
||||
header_params.update(self.default_headers)
|
||||
if self.cookie:
|
||||
header_params['Cookie'] = self.cookie
|
||||
if header_params:
|
||||
header_params = self.sanitize_for_serialization(header_params)
|
||||
|
||||
# path parameters
|
||||
if path_params:
|
||||
path_params = self.sanitize_for_serialization(path_params)
|
||||
for k, v in iteritems(path_params):
|
||||
replacement = quote(str(self.to_path_value(v)))
|
||||
resource_path = resource_path.replace('{' + k + '}', replacement)
|
||||
# path parameters
|
||||
if path_params:
|
||||
path_params = self.sanitize_for_serialization(path_params)
|
||||
for k, v in iteritems(path_params):
|
||||
replacement = quote(str(self.to_path_value(v)))
|
||||
resource_path = resource_path.replace('{' + k + '}', replacement)
|
||||
|
||||
# query parameters
|
||||
if query_params:
|
||||
query_params = self.sanitize_for_serialization(query_params)
|
||||
query_params = {k: self.to_path_value(v) for k, v in iteritems(query_params)}
|
||||
# query parameters
|
||||
if query_params:
|
||||
query_params = self.sanitize_for_serialization(query_params)
|
||||
query_params = {k: self.to_path_value(v) for k, v in iteritems(query_params)}
|
||||
|
||||
# post parameters
|
||||
if post_params:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
# post parameters
|
||||
if post_params:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
|
||||
# auth setting
|
||||
self.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
# auth setting
|
||||
self.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
|
||||
# body
|
||||
if body:
|
||||
body = self.sanitize_for_serialization(body)
|
||||
# body
|
||||
if body:
|
||||
body = self.sanitize_for_serialization(body)
|
||||
|
||||
# request url
|
||||
url = self.host + resource_path
|
||||
# request url
|
||||
url = self.host + resource_path
|
||||
|
||||
# perform request and return response
|
||||
response_data = self.request(method, url, query_params=query_params, headers=header_params,
|
||||
post_params=post_params, body=body)
|
||||
# perform request and return response
|
||||
response_data = self.request(method, url, query_params=query_params, headers=header_params,
|
||||
post_params=post_params, body=body)
|
||||
|
||||
# deserialize response data
|
||||
if response:
|
||||
return self.deserialize(response_data, response)
|
||||
else:
|
||||
return None
|
||||
# deserialize response data
|
||||
if response:
|
||||
return self.deserialize(response_data, response)
|
||||
else:
|
||||
return None
|
||||
|
||||
def to_path_value(self, obj):
|
||||
"""
|
||||
Convert a string or object to a path-friendly value
|
||||
def to_path_value(self, obj):
|
||||
"""
|
||||
Convert a string or object to a path-friendly value
|
||||
|
||||
:param obj: object or string value
|
||||
:param obj: object or string value
|
||||
|
||||
:return string: quoted value
|
||||
"""
|
||||
if type(obj) == list:
|
||||
return ','.join(obj)
|
||||
else:
|
||||
return str(obj)
|
||||
:return string: quoted value
|
||||
"""
|
||||
if type(obj) == list:
|
||||
return ','.join(obj)
|
||||
else:
|
||||
return str(obj)
|
||||
|
||||
def sanitize_for_serialization(self, obj):
|
||||
"""
|
||||
Sanitize an object for Request.
|
||||
def sanitize_for_serialization(self, obj):
|
||||
"""
|
||||
Sanitize an object for Request.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is str, int, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date convert to string in iso8601 format.
|
||||
If obj is list, santize each element in the list.
|
||||
If obj is dict, return the dict.
|
||||
If obj is swagger model, return the properties dict.
|
||||
"""
|
||||
if isinstance(obj, type(None)):
|
||||
return None
|
||||
elif isinstance(obj, (str, int, float, bool, tuple)):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
|
||||
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
||||
return obj.isoformat()
|
||||
else:
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
else:
|
||||
# Convert model obj to dict except attributes `swagger_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in model definition for request.
|
||||
obj_dict = {obj.attribute_map[key]: val
|
||||
for key, val in iteritems(obj.__dict__)
|
||||
if key != 'swagger_types' and key != 'attribute_map' and val is not None}
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in iteritems(obj_dict)}
|
||||
If obj is None, return None.
|
||||
If obj is str, int, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date convert to string in iso8601 format.
|
||||
If obj is list, santize each element in the list.
|
||||
If obj is dict, return the dict.
|
||||
If obj is swagger model, return the properties dict.
|
||||
"""
|
||||
if isinstance(obj, type(None)):
|
||||
return None
|
||||
elif isinstance(obj, (str, int, float, bool, tuple)):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
|
||||
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
||||
return obj.isoformat()
|
||||
else:
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
else:
|
||||
# Convert model obj to dict except attributes `swagger_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in model definition for request.
|
||||
obj_dict = {obj.attribute_map[key]: val
|
||||
for key, val in iteritems(obj.__dict__)
|
||||
if key != 'swagger_types' and key != 'attribute_map' and val is not None}
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in iteritems(obj_dict)}
|
||||
|
||||
def deserialize(self, obj, obj_class):
|
||||
"""
|
||||
Derialize a JSON string into an object.
|
||||
def deserialize(self, obj, obj_class):
|
||||
"""
|
||||
Derialize a JSON string into an object.
|
||||
|
||||
:param obj: string or object to be deserialized
|
||||
:param obj_class: class literal for deserialzied object, or string of class name
|
||||
:param obj: string or object to be deserialized
|
||||
:param obj_class: class literal for deserialzied object, or string of class name
|
||||
|
||||
:return object: deserialized object
|
||||
"""
|
||||
# Have to accept obj_class as string or actual type. Type could be a
|
||||
# native Python type, or one of the model classes.
|
||||
if type(obj_class) == str:
|
||||
if 'list[' in obj_class:
|
||||
match = re.match('list\[(.*)\]', obj_class)
|
||||
sub_class = match.group(1)
|
||||
return [self.deserialize(sub_obj, sub_class) for sub_obj in obj]
|
||||
:return object: deserialized object
|
||||
"""
|
||||
# Have to accept obj_class as string or actual type. Type could be a
|
||||
# native Python type, or one of the model classes.
|
||||
if type(obj_class) == str:
|
||||
if 'list[' in obj_class:
|
||||
match = re.match('list\[(.*)\]', obj_class)
|
||||
sub_class = match.group(1)
|
||||
return [self.deserialize(sub_obj, sub_class) for sub_obj in obj]
|
||||
|
||||
if obj_class in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']:
|
||||
obj_class = eval(obj_class)
|
||||
else: # not a native type, must be model class
|
||||
obj_class = eval('models.' + obj_class)
|
||||
if obj_class in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']:
|
||||
obj_class = eval(obj_class)
|
||||
else: # not a native type, must be model class
|
||||
obj_class = eval('models.' + obj_class)
|
||||
|
||||
if obj_class in [int, float, dict, list, str, bool]:
|
||||
return obj_class(obj)
|
||||
elif obj_class == datetime:
|
||||
return self.__parse_string_to_datetime(obj)
|
||||
if obj_class in [int, float, dict, list, str, bool]:
|
||||
return obj_class(obj)
|
||||
elif obj_class == datetime:
|
||||
return self.__parse_string_to_datetime(obj)
|
||||
|
||||
instance = obj_class()
|
||||
instance = obj_class()
|
||||
|
||||
for attr, attr_type in iteritems(instance.swagger_types):
|
||||
if obj is not None and instance.attribute_map[attr] in obj and type(obj) in [list, dict]:
|
||||
value = obj[instance.attribute_map[attr]]
|
||||
if attr_type in ['str', 'int', 'float', 'bool']:
|
||||
attr_type = eval(attr_type)
|
||||
try:
|
||||
value = attr_type(value)
|
||||
except UnicodeEncodeError:
|
||||
value = unicode(value)
|
||||
except TypeError:
|
||||
value = value
|
||||
setattr(instance, attr, value)
|
||||
elif attr_type == 'datetime':
|
||||
setattr(instance, attr, self.__parse_string_to_datetime(value))
|
||||
elif 'list[' in attr_type:
|
||||
match = re.match('list\[(.*)\]', attr_type)
|
||||
sub_class = match.group(1)
|
||||
sub_values = []
|
||||
if not value:
|
||||
setattr(instance, attr, None)
|
||||
else:
|
||||
for sub_value in value:
|
||||
sub_values.append(self.deserialize(sub_value, sub_class))
|
||||
setattr(instance, attr, sub_values)
|
||||
else:
|
||||
setattr(instance, attr, self.deserialize(value, attr_type))
|
||||
for attr, attr_type in iteritems(instance.swagger_types):
|
||||
if obj is not None and instance.attribute_map[attr] in obj and type(obj) in [list, dict]:
|
||||
value = obj[instance.attribute_map[attr]]
|
||||
if attr_type in ['str', 'int', 'float', 'bool']:
|
||||
attr_type = eval(attr_type)
|
||||
try:
|
||||
value = attr_type(value)
|
||||
except UnicodeEncodeError:
|
||||
value = unicode(value)
|
||||
except TypeError:
|
||||
value = value
|
||||
setattr(instance, attr, value)
|
||||
elif attr_type == 'datetime':
|
||||
setattr(instance, attr, self.__parse_string_to_datetime(value))
|
||||
elif 'list[' in attr_type:
|
||||
match = re.match('list\[(.*)\]', attr_type)
|
||||
sub_class = match.group(1)
|
||||
sub_values = []
|
||||
if not value:
|
||||
setattr(instance, attr, None)
|
||||
else:
|
||||
for sub_value in value:
|
||||
sub_values.append(self.deserialize(sub_value, sub_class))
|
||||
setattr(instance, attr, sub_values)
|
||||
else:
|
||||
setattr(instance, attr, self.deserialize(value, attr_type))
|
||||
|
||||
return instance
|
||||
return instance
|
||||
|
||||
def __parse_string_to_datetime(self, string):
|
||||
"""
|
||||
Parse datetime in string to datetime.
|
||||
def __parse_string_to_datetime(self, string):
|
||||
"""
|
||||
Parse datetime in string to datetime.
|
||||
|
||||
The string should be in iso8601 datetime format.
|
||||
"""
|
||||
try:
|
||||
from dateutil.parser import parse
|
||||
return parse(string)
|
||||
except ImportError:
|
||||
return string
|
||||
The string should be in iso8601 datetime format.
|
||||
"""
|
||||
try:
|
||||
from dateutil.parser import parse
|
||||
return parse(string)
|
||||
except ImportError:
|
||||
return string
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None):
|
||||
"""
|
||||
Perform http request using RESTClient.
|
||||
"""
|
||||
if method == "GET":
|
||||
return RESTClient.GET(url, query_params=query_params, headers=headers)
|
||||
elif method == "HEAD":
|
||||
return RESTClient.HEAD(url, query_params=query_params, headers=headers)
|
||||
elif method == "POST":
|
||||
return RESTClient.POST(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "PUT":
|
||||
return RESTClient.PUT(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "PATCH":
|
||||
return RESTClient.PATCH(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "DELETE":
|
||||
return RESTClient.DELETE(url, query_params=query_params, headers=headers)
|
||||
else:
|
||||
raise ValueError("http method must be `GET`, `HEAD`, `POST`, `PATCH`, `PUT` or `DELETE`")
|
||||
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None):
|
||||
"""
|
||||
Perform http request using RESTClient.
|
||||
"""
|
||||
if method == "GET":
|
||||
return RESTClient.GET(url, query_params=query_params, headers=headers)
|
||||
elif method == "HEAD":
|
||||
return RESTClient.HEAD(url, query_params=query_params, headers=headers)
|
||||
elif method == "POST":
|
||||
return RESTClient.POST(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "PUT":
|
||||
return RESTClient.PUT(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "PATCH":
|
||||
return RESTClient.PATCH(url, headers=headers, post_params=post_params, body=body)
|
||||
elif method == "DELETE":
|
||||
return RESTClient.DELETE(url, query_params=query_params, headers=headers)
|
||||
else:
|
||||
raise ValueError("http method must be `GET`, `HEAD`, `POST`, `PATCH`, `PUT` or `DELETE`")
|
||||
|
||||
def prepare_post_parameters(self, post_params=None, files=None):
|
||||
params = {}
|
||||
def prepare_post_parameters(self, post_params=None, files=None):
|
||||
params = {}
|
||||
|
||||
if post_params:
|
||||
params.update(post_params)
|
||||
if post_params:
|
||||
params.update(post_params)
|
||||
|
||||
if files:
|
||||
for k, v in iteritems(files):
|
||||
if v:
|
||||
with open(v, 'rb') as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
|
||||
params[k] = tuple([filename, filedata, mimetype])
|
||||
if files:
|
||||
for k, v in iteritems(files):
|
||||
if v:
|
||||
with open(v, 'rb') as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
|
||||
params[k] = tuple([filename, filedata, mimetype])
|
||||
|
||||
return params
|
||||
return params
|
||||
|
||||
def select_header_accept(self, accepts):
|
||||
"""
|
||||
Return `Accept` based on an array of accepts provided
|
||||
"""
|
||||
if not accepts:
|
||||
return
|
||||
def select_header_accept(self, accepts):
|
||||
"""
|
||||
Return `Accept` based on an array of accepts provided
|
||||
"""
|
||||
if not accepts:
|
||||
return
|
||||
|
||||
accepts = list(map(lambda x: x.lower(), accepts))
|
||||
accepts = list(map(lambda x: x.lower(), accepts))
|
||||
|
||||
if 'application/json' in accepts:
|
||||
return 'application/json'
|
||||
else:
|
||||
return ', '.join(accepts)
|
||||
if 'application/json' in accepts:
|
||||
return 'application/json'
|
||||
else:
|
||||
return ', '.join(accepts)
|
||||
|
||||
def select_header_content_type(self, content_types):
|
||||
"""
|
||||
Return `Content-Type` baseed on an array of content_types provided
|
||||
"""
|
||||
if not content_types:
|
||||
return 'application/json'
|
||||
def select_header_content_type(self, content_types):
|
||||
"""
|
||||
Return `Content-Type` baseed on an array of content_types provided
|
||||
"""
|
||||
if not content_types:
|
||||
return 'application/json'
|
||||
|
||||
content_types = list(map(lambda x: x.lower(), content_types))
|
||||
content_types = list(map(lambda x: x.lower(), content_types))
|
||||
|
||||
if 'application/json' in content_types:
|
||||
return 'application/json'
|
||||
else:
|
||||
return content_types[0]
|
||||
if 'application/json' in content_types:
|
||||
return 'application/json'
|
||||
else:
|
||||
return content_types[0]
|
||||
|
||||
def update_params_for_auth(self, headers, querys, auth_settings):
|
||||
"""
|
||||
Update header and query params based on authentication setting
|
||||
"""
|
||||
if not auth_settings:
|
||||
return
|
||||
|
||||
for auth in auth_settings:
|
||||
auth_setting = configuration.auth_settings().get(auth)
|
||||
if auth_setting:
|
||||
if auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
elif auth_setting['in'] == 'query':
|
||||
querys[auth_setting['key']] = auth_setting['value']
|
||||
else:
|
||||
raise ValueError('Authentication token must be in `query` or `header`')
|
||||
def update_params_for_auth(self, headers, querys, auth_settings):
|
||||
"""
|
||||
Update header and query params based on authentication setting
|
||||
"""
|
||||
if not auth_settings:
|
||||
return
|
||||
|
||||
for auth in auth_settings:
|
||||
auth_setting = configuration.auth_settings().get(auth)
|
||||
if auth_setting:
|
||||
if auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
elif auth_setting['in'] == 'query':
|
||||
querys[auth_setting['key']] = auth_setting['value']
|
||||
else:
|
||||
raise ValueError('Authentication token must be in `query` or `header`')
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
PetApi.py
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
@@ -30,18 +30,18 @@ from six import iteritems
|
||||
from .. import configuration
|
||||
from ..api_client import ApiClient
|
||||
|
||||
class PetApi(object):
|
||||
class PetApi(object):
|
||||
|
||||
def __init__(self, api_client=None):
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
|
||||
|
||||
|
||||
def update_pet(self, **kwargs):
|
||||
def update_pet(self, **kwargs):
|
||||
"""
|
||||
Update an existing pet
|
||||
|
||||
@@ -55,9 +55,9 @@ class PetApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet'.replace('{format}', 'json')
|
||||
@@ -74,13 +74,13 @@ class PetApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json', 'application/xml'])
|
||||
@@ -89,10 +89,10 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def add_pet(self, **kwargs):
|
||||
def add_pet(self, **kwargs):
|
||||
"""
|
||||
Add a new pet to the store
|
||||
|
||||
@@ -106,9 +106,9 @@ class PetApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method add_pet" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method add_pet" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet'.replace('{format}', 'json')
|
||||
@@ -125,13 +125,13 @@ class PetApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json', 'application/xml'])
|
||||
@@ -140,10 +140,10 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def find_pets_by_status(self, **kwargs):
|
||||
def find_pets_by_status(self, **kwargs):
|
||||
"""
|
||||
Finds Pets by status
|
||||
Multiple status values can be provided with comma seperated strings
|
||||
@@ -157,9 +157,9 @@ class PetApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_status" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_status" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/findByStatus'.replace('{format}', 'json')
|
||||
@@ -169,7 +169,7 @@ class PetApi(object):
|
||||
|
||||
query_params = {}
|
||||
|
||||
if 'status' in params:
|
||||
if 'status' in params:
|
||||
query_params['status'] = params['status']
|
||||
|
||||
header_params = {}
|
||||
@@ -182,7 +182,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -191,12 +191,12 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='list[Pet]', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='list[Pet]', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def find_pets_by_tags(self, **kwargs):
|
||||
def find_pets_by_tags(self, **kwargs):
|
||||
"""
|
||||
Finds Pets by tags
|
||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
@@ -210,9 +210,9 @@ class PetApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_tags" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_tags" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/findByTags'.replace('{format}', 'json')
|
||||
@@ -222,7 +222,7 @@ class PetApi(object):
|
||||
|
||||
query_params = {}
|
||||
|
||||
if 'tags' in params:
|
||||
if 'tags' in params:
|
||||
query_params['tags'] = params['tags']
|
||||
|
||||
header_params = {}
|
||||
@@ -235,7 +235,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -244,12 +244,12 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='list[Pet]', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='list[Pet]', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def get_pet_by_id(self, pet_id, **kwargs):
|
||||
def get_pet_by_id(self, pet_id, **kwargs):
|
||||
"""
|
||||
Find pet by ID
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
@@ -259,17 +259,17 @@ class PetApi(object):
|
||||
:return: Pet
|
||||
"""
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`")
|
||||
|
||||
all_params = ['pet_id']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_pet_by_id" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_pet_by_id" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
@@ -277,8 +277,8 @@ class PetApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -292,7 +292,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -301,12 +301,12 @@ class PetApi(object):
|
||||
auth_settings = ['api_key', 'petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Pet', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Pet', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def update_pet_with_form(self, pet_id, **kwargs):
|
||||
def update_pet_with_form(self, pet_id, **kwargs):
|
||||
"""
|
||||
Updates a pet in the store with form data
|
||||
|
||||
@@ -318,17 +318,17 @@ class PetApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`")
|
||||
|
||||
all_params = ['pet_id', 'name', 'status']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet_with_form" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet_with_form" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
@@ -336,8 +336,8 @@ class PetApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -346,10 +346,10 @@ class PetApi(object):
|
||||
form_params = {}
|
||||
files = {}
|
||||
|
||||
if 'name' in params:
|
||||
if 'name' in params:
|
||||
form_params['name'] = params['name']
|
||||
|
||||
if 'status' in params:
|
||||
if 'status' in params:
|
||||
form_params['status'] = params['status']
|
||||
|
||||
body_params = None
|
||||
@@ -357,7 +357,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/x-www-form-urlencoded'])
|
||||
@@ -366,10 +366,10 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def delete_pet(self, pet_id, **kwargs):
|
||||
def delete_pet(self, pet_id, **kwargs):
|
||||
"""
|
||||
Deletes a pet
|
||||
|
||||
@@ -380,17 +380,17 @@ class PetApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`")
|
||||
|
||||
all_params = ['api_key', 'pet_id']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_pet" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_pet" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
@@ -398,14 +398,14 @@ class PetApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
header_params = {}
|
||||
|
||||
if 'api_key' in params:
|
||||
if 'api_key' in params:
|
||||
header_params['api_key'] = params['api_key']
|
||||
|
||||
form_params = {}
|
||||
@@ -416,7 +416,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -425,10 +425,10 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def upload_file(self, pet_id, **kwargs):
|
||||
def upload_file(self, pet_id, **kwargs):
|
||||
"""
|
||||
uploads an image
|
||||
|
||||
@@ -440,17 +440,17 @@ class PetApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if pet_id is None:
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`")
|
||||
|
||||
all_params = ['pet_id', 'additional_metadata', 'file']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method upload_file" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method upload_file" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json')
|
||||
@@ -458,8 +458,8 @@ class PetApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -468,10 +468,10 @@ class PetApi(object):
|
||||
form_params = {}
|
||||
files = {}
|
||||
|
||||
if 'additional_metadata' in params:
|
||||
if 'additional_metadata' in params:
|
||||
form_params['additionalMetadata'] = params['additional_metadata']
|
||||
|
||||
if 'file' in params:
|
||||
if 'file' in params:
|
||||
files['file'] = params['file']
|
||||
|
||||
body_params = None
|
||||
@@ -479,7 +479,7 @@ class PetApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type(['multipart/form-data'])
|
||||
@@ -488,8 +488,8 @@ class PetApi(object):
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
StoreApi.py
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
@@ -30,18 +30,18 @@ from six import iteritems
|
||||
from .. import configuration
|
||||
from ..api_client import ApiClient
|
||||
|
||||
class StoreApi(object):
|
||||
class StoreApi(object):
|
||||
|
||||
def __init__(self, api_client=None):
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
|
||||
|
||||
|
||||
def get_inventory(self, **kwargs):
|
||||
def get_inventory(self, **kwargs):
|
||||
"""
|
||||
Returns pet inventories by status
|
||||
Returns a map of status codes to quantities
|
||||
@@ -54,9 +54,9 @@ class StoreApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_inventory" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_inventory" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/store/inventory'.replace('{format}', 'json')
|
||||
@@ -76,7 +76,7 @@ class StoreApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -85,12 +85,12 @@ class StoreApi(object):
|
||||
auth_settings = ['api_key']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='map(String, int)', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='map(String, int)', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def place_order(self, **kwargs):
|
||||
def place_order(self, **kwargs):
|
||||
"""
|
||||
Place an order for a pet
|
||||
|
||||
@@ -104,9 +104,9 @@ class StoreApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method place_order" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method place_order" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/store/order'.replace('{format}', 'json')
|
||||
@@ -123,13 +123,13 @@ class StoreApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -138,12 +138,12 @@ class StoreApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Order', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Order', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def get_order_by_id(self, order_id, **kwargs):
|
||||
def get_order_by_id(self, order_id, **kwargs):
|
||||
"""
|
||||
Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
@@ -153,17 +153,17 @@ class StoreApi(object):
|
||||
:return: Order
|
||||
"""
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
if order_id is None:
|
||||
# verify the required parameter 'order_id' is set
|
||||
if order_id is None:
|
||||
raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`")
|
||||
|
||||
all_params = ['order_id']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_order_by_id" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_order_by_id" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
|
||||
@@ -171,8 +171,8 @@ class StoreApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'order_id' in params:
|
||||
path_params['orderId'] = params['order_id']
|
||||
if 'order_id' in params:
|
||||
path_params['orderId'] = params['order_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -186,7 +186,7 @@ class StoreApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -195,12 +195,12 @@ class StoreApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Order', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='Order', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def delete_order(self, order_id, **kwargs):
|
||||
def delete_order(self, order_id, **kwargs):
|
||||
"""
|
||||
Delete purchase order by ID
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@@ -210,17 +210,17 @@ class StoreApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
if order_id is None:
|
||||
# verify the required parameter 'order_id' is set
|
||||
if order_id is None:
|
||||
raise ValueError("Missing the required parameter `order_id` when calling `delete_order`")
|
||||
|
||||
all_params = ['order_id']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_order" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_order" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
|
||||
@@ -228,8 +228,8 @@ class StoreApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'order_id' in params:
|
||||
path_params['orderId'] = params['order_id']
|
||||
if 'order_id' in params:
|
||||
path_params['orderId'] = params['order_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -243,7 +243,7 @@ class StoreApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -252,8 +252,8 @@ class StoreApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
UserApi.py
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
@@ -30,18 +30,18 @@ from six import iteritems
|
||||
from .. import configuration
|
||||
from ..api_client import ApiClient
|
||||
|
||||
class UserApi(object):
|
||||
class UserApi(object):
|
||||
|
||||
def __init__(self, api_client=None):
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not configuration.api_client:
|
||||
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||
self.api_client = configuration.api_client
|
||||
|
||||
|
||||
|
||||
def create_user(self, **kwargs):
|
||||
def create_user(self, **kwargs):
|
||||
"""
|
||||
Create user
|
||||
This can only be done by the logged in user.
|
||||
@@ -55,9 +55,9 @@ class UserApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_user" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_user" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user'.replace('{format}', 'json')
|
||||
@@ -74,13 +74,13 @@ class UserApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -89,10 +89,10 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def create_users_with_array_input(self, **kwargs):
|
||||
def create_users_with_array_input(self, **kwargs):
|
||||
"""
|
||||
Creates list of users with given input array
|
||||
|
||||
@@ -106,9 +106,9 @@ class UserApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_array_input" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_array_input" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/createWithArray'.replace('{format}', 'json')
|
||||
@@ -125,13 +125,13 @@ class UserApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -140,10 +140,10 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def create_users_with_list_input(self, **kwargs):
|
||||
def create_users_with_list_input(self, **kwargs):
|
||||
"""
|
||||
Creates list of users with given input array
|
||||
|
||||
@@ -157,9 +157,9 @@ class UserApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_list_input" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_list_input" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/createWithList'.replace('{format}', 'json')
|
||||
@@ -176,13 +176,13 @@ class UserApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -191,10 +191,10 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def login_user(self, **kwargs):
|
||||
def login_user(self, **kwargs):
|
||||
"""
|
||||
Logs user into the system
|
||||
|
||||
@@ -209,9 +209,9 @@ class UserApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method login_user" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method login_user" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/login'.replace('{format}', 'json')
|
||||
@@ -221,10 +221,10 @@ class UserApi(object):
|
||||
|
||||
query_params = {}
|
||||
|
||||
if 'username' in params:
|
||||
if 'username' in params:
|
||||
query_params['username'] = params['username']
|
||||
|
||||
if 'password' in params:
|
||||
if 'password' in params:
|
||||
query_params['password'] = params['password']
|
||||
|
||||
header_params = {}
|
||||
@@ -237,7 +237,7 @@ class UserApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -246,12 +246,12 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='str', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='str', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def logout_user(self, **kwargs):
|
||||
def logout_user(self, **kwargs):
|
||||
"""
|
||||
Logs out current logged in user session
|
||||
|
||||
@@ -264,9 +264,9 @@ class UserApi(object):
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method logout_user" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method logout_user" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/logout'.replace('{format}', 'json')
|
||||
@@ -286,7 +286,7 @@ class UserApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -295,10 +295,10 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def get_user_by_name(self, username, **kwargs):
|
||||
def get_user_by_name(self, username, **kwargs):
|
||||
"""
|
||||
Get user by user name
|
||||
|
||||
@@ -308,17 +308,17 @@ class UserApi(object):
|
||||
:return: User
|
||||
"""
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`")
|
||||
|
||||
all_params = ['username']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_user_by_name" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_user_by_name" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
@@ -326,8 +326,8 @@ class UserApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -341,7 +341,7 @@ class UserApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -350,12 +350,12 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='User', auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response='User', auth_settings=auth_settings)
|
||||
|
||||
return response
|
||||
return response
|
||||
|
||||
def update_user(self, username, **kwargs):
|
||||
def update_user(self, username, **kwargs):
|
||||
"""
|
||||
Updated user
|
||||
This can only be done by the logged in user.
|
||||
@@ -366,17 +366,17 @@ class UserApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
raise ValueError("Missing the required parameter `username` when calling `update_user`")
|
||||
|
||||
all_params = ['username', 'body']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_user" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_user" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
@@ -384,8 +384,8 @@ class UserApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -396,13 +396,13 @@ class UserApi(object):
|
||||
|
||||
body_params = None
|
||||
|
||||
if 'body' in params:
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -411,10 +411,10 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
def delete_user(self, username, **kwargs):
|
||||
def delete_user(self, username, **kwargs):
|
||||
"""
|
||||
Delete user
|
||||
This can only be done by the logged in user.
|
||||
@@ -424,17 +424,17 @@ class UserApi(object):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
# verify the required parameter 'username' is set
|
||||
if username is None:
|
||||
raise ValueError("Missing the required parameter `username` when calling `delete_user`")
|
||||
|
||||
all_params = ['username']
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_user" % key)
|
||||
params[key] = val
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_user" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
@@ -442,8 +442,8 @@ class UserApi(object):
|
||||
|
||||
path_params = {}
|
||||
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
if 'username' in params:
|
||||
path_params['username'] = params['username']
|
||||
|
||||
query_params = {}
|
||||
|
||||
@@ -457,7 +457,7 @@ class UserApi(object):
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
@@ -466,8 +466,8 @@ class UserApi(object):
|
||||
auth_settings = []
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response=None, auth_settings=auth_settings)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,37 +3,37 @@ import base64
|
||||
import urllib3
|
||||
|
||||
def get_api_key_with_prefix(key):
|
||||
global api_key
|
||||
global api_key_prefix
|
||||
global api_key
|
||||
global api_key_prefix
|
||||
|
||||
if api_key.get(key) and api_key_prefix.get(key):
|
||||
return api_key_prefix[key] + ' ' + api_key[key]
|
||||
elif api_key.get(key):
|
||||
return api_key[key]
|
||||
if api_key.get(key) and api_key_prefix.get(key):
|
||||
return api_key_prefix[key] + ' ' + api_key[key]
|
||||
elif api_key.get(key):
|
||||
return api_key[key]
|
||||
|
||||
def get_basic_auth_token():
|
||||
global username
|
||||
global password
|
||||
global username
|
||||
global password
|
||||
|
||||
return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization')
|
||||
return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization')
|
||||
|
||||
def auth_settings():
|
||||
return {
|
||||
'api_key': {
|
||||
'type': 'api_key',
|
||||
'in': 'header',
|
||||
'key': 'api_key',
|
||||
'value': get_api_key_with_prefix('api_key')
|
||||
},
|
||||
|
||||
}
|
||||
return {
|
||||
'api_key': {
|
||||
'type': 'api_key',
|
||||
'in': 'header',
|
||||
'key': 'api_key',
|
||||
'value': get_api_key_with_prefix('api_key')
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
# Default Base url
|
||||
host = "http://petstore.swagger.io/v2"
|
||||
|
||||
# Default api client
|
||||
api_client = None
|
||||
|
||||
|
||||
# Authentication settings
|
||||
|
||||
api_key = {}
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
"""
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class Category(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
class Category(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
|
||||
@@ -31,28 +32,29 @@ class Category(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'id': 'id',
|
||||
'name': 'name'
|
||||
'id': 'id',
|
||||
'name': 'name'
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.id = None # int
|
||||
|
||||
|
||||
self.name = None # str
|
||||
|
||||
self.name = None # str
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__, props=' '.join(properties))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
"""
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class Order(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
class Order(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
|
||||
@@ -31,48 +32,49 @@ class Order(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'id': 'int',
|
||||
'pet_id': 'int',
|
||||
'quantity': 'int',
|
||||
'ship_date': 'DateTime',
|
||||
'status': 'str',
|
||||
'complete': 'bool'
|
||||
'id': 'int',
|
||||
'pet_id': 'int',
|
||||
'quantity': 'int',
|
||||
'ship_date': 'DateTime',
|
||||
'status': 'str',
|
||||
'complete': 'bool'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'id': 'id',
|
||||
'pet_id': 'petId',
|
||||
'quantity': 'quantity',
|
||||
'ship_date': 'shipDate',
|
||||
'status': 'status',
|
||||
'complete': 'complete'
|
||||
'id': 'id',
|
||||
'pet_id': 'petId',
|
||||
'quantity': 'quantity',
|
||||
'ship_date': 'shipDate',
|
||||
'status': 'status',
|
||||
'complete': 'complete'
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.pet_id = None # int
|
||||
|
||||
|
||||
self.quantity = None # int
|
||||
|
||||
self.pet_id = None # int
|
||||
|
||||
self.ship_date = None # DateTime
|
||||
|
||||
# Order Status
|
||||
self.status = None # str
|
||||
|
||||
self.quantity = None # int
|
||||
|
||||
|
||||
self.ship_date = None # DateTime
|
||||
|
||||
# Order Status
|
||||
self.status = None # str
|
||||
|
||||
|
||||
self.complete = None # bool
|
||||
|
||||
self.complete = None # bool
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__, props=' '.join(properties))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
"""
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class Pet(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
class Pet(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
|
||||
@@ -31,48 +32,49 @@ class Pet(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'id': 'int',
|
||||
'category': 'Category',
|
||||
'name': 'str',
|
||||
'photo_urls': 'list[str]',
|
||||
'tags': 'list[Tag]',
|
||||
'status': 'str'
|
||||
'id': 'int',
|
||||
'category': 'Category',
|
||||
'name': 'str',
|
||||
'photo_urls': 'list[str]',
|
||||
'tags': 'list[Tag]',
|
||||
'status': 'str'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'id': 'id',
|
||||
'category': 'category',
|
||||
'name': 'name',
|
||||
'photo_urls': 'photoUrls',
|
||||
'tags': 'tags',
|
||||
'status': 'status'
|
||||
'id': 'id',
|
||||
'category': 'category',
|
||||
'name': 'name',
|
||||
'photo_urls': 'photoUrls',
|
||||
'tags': 'tags',
|
||||
'status': 'status'
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.category = None # Category
|
||||
|
||||
|
||||
self.name = None # str
|
||||
|
||||
self.category = None # Category
|
||||
|
||||
self.photo_urls = None # list[str]
|
||||
|
||||
|
||||
self.tags = None # list[Tag]
|
||||
|
||||
self.name = None # str
|
||||
|
||||
|
||||
self.photo_urls = None # list[str]
|
||||
|
||||
|
||||
self.tags = None # list[Tag]
|
||||
|
||||
# pet status in the store
|
||||
self.status = None # str
|
||||
# pet status in the store
|
||||
self.status = None # str
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__, props=' '.join(properties))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
"""
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class Tag(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
class Tag(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
|
||||
@@ -31,28 +32,29 @@ class Tag(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'id': 'id',
|
||||
'name': 'name'
|
||||
'id': 'id',
|
||||
'name': 'name'
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.id = None # int
|
||||
|
||||
|
||||
self.name = None # str
|
||||
|
||||
self.name = None # str
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__, props=' '.join(properties))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
"""
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class User(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
class User(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
|
||||
@@ -31,58 +32,59 @@ class User(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'id': 'int',
|
||||
'username': 'str',
|
||||
'first_name': 'str',
|
||||
'last_name': 'str',
|
||||
'email': 'str',
|
||||
'password': 'str',
|
||||
'phone': 'str',
|
||||
'user_status': 'int'
|
||||
'id': 'int',
|
||||
'username': 'str',
|
||||
'first_name': 'str',
|
||||
'last_name': 'str',
|
||||
'email': 'str',
|
||||
'password': 'str',
|
||||
'phone': 'str',
|
||||
'user_status': 'int'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'id': 'id',
|
||||
'username': 'username',
|
||||
'first_name': 'firstName',
|
||||
'last_name': 'lastName',
|
||||
'email': 'email',
|
||||
'password': 'password',
|
||||
'phone': 'phone',
|
||||
'user_status': 'userStatus'
|
||||
'id': 'id',
|
||||
'username': 'username',
|
||||
'first_name': 'firstName',
|
||||
'last_name': 'lastName',
|
||||
'email': 'email',
|
||||
'password': 'password',
|
||||
'phone': 'phone',
|
||||
'user_status': 'userStatus'
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.id = None # int
|
||||
|
||||
self.username = None # str
|
||||
|
||||
|
||||
self.first_name = None # str
|
||||
|
||||
self.username = None # str
|
||||
|
||||
self.last_name = None # str
|
||||
|
||||
|
||||
self.email = None # str
|
||||
|
||||
self.first_name = None # str
|
||||
|
||||
self.password = None # str
|
||||
|
||||
|
||||
self.phone = None # str
|
||||
|
||||
self.last_name = None # str
|
||||
|
||||
|
||||
self.email = None # str
|
||||
|
||||
|
||||
self.password = None # str
|
||||
|
||||
|
||||
self.phone = None # str
|
||||
|
||||
# User Status
|
||||
self.user_status = None # int
|
||||
# User Status
|
||||
self.user_status = None # int
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p]))
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__, props=' '.join(properties))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,239 +15,239 @@ import certifi
|
||||
from six import iteritems
|
||||
|
||||
try:
|
||||
import urllib3
|
||||
import urllib3
|
||||
except ImportError:
|
||||
raise ImportError('Swagger python client requires urllib3.')
|
||||
raise ImportError('Swagger python client requires urllib3.')
|
||||
|
||||
try:
|
||||
# for python3
|
||||
from urllib.parse import urlencode
|
||||
# for python3
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
# for python2
|
||||
from urllib import urlencode
|
||||
# for python2
|
||||
from urllib import urlencode
|
||||
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
|
||||
def __init__(self, resp):
|
||||
self.urllib3_response = resp
|
||||
self.status = resp.status
|
||||
self.reason = resp.reason
|
||||
self.data = resp.data
|
||||
def __init__(self, resp):
|
||||
self.urllib3_response = resp
|
||||
self.status = resp.status
|
||||
self.reason = resp.reason
|
||||
self.data = resp.data
|
||||
|
||||
def getheaders(self):
|
||||
"""
|
||||
Returns a dictionary of the response headers.
|
||||
"""
|
||||
return self.urllib3_response.getheaders()
|
||||
def getheaders(self):
|
||||
"""
|
||||
Returns a dictionary of the response headers.
|
||||
"""
|
||||
return self.urllib3_response.getheaders()
|
||||
|
||||
def getheader(self, name, default=None):
|
||||
"""
|
||||
Returns a given response header.
|
||||
"""
|
||||
return self.urllib3_response.getheader(name, default)
|
||||
def getheader(self, name, default=None):
|
||||
"""
|
||||
Returns a given response header.
|
||||
"""
|
||||
return self.urllib3_response.getheader(name, default)
|
||||
|
||||
class RESTClientObject(object):
|
||||
|
||||
def __init__(self, pools_size=4):
|
||||
# http pool manager
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size
|
||||
)
|
||||
def __init__(self, pools_size=4):
|
||||
# http pool manager
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size
|
||||
)
|
||||
|
||||
# https pool manager
|
||||
# certificates validated using Mozilla’s root certificates
|
||||
self.ssl_pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size,
|
||||
cert_reqs=ssl.CERT_REQUIRED,
|
||||
ca_certs=certifi.where()
|
||||
)
|
||||
# https pool manager
|
||||
# certificates validated using Mozilla’s root certificates
|
||||
self.ssl_pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size,
|
||||
cert_reqs=ssl.CERT_REQUIRED,
|
||||
ca_certs=certifi.where()
|
||||
)
|
||||
|
||||
def agent(self, url):
|
||||
"""
|
||||
Return proper pool manager for the http\https schemes.
|
||||
"""
|
||||
url = urllib3.util.url.parse_url(url)
|
||||
scheme = url.scheme
|
||||
if scheme == 'https':
|
||||
return self.ssl_pool_manager
|
||||
else:
|
||||
return self.pool_manager
|
||||
def agent(self, url):
|
||||
"""
|
||||
Return proper pool manager for the http\https schemes.
|
||||
"""
|
||||
url = urllib3.util.url.parse_url(url)
|
||||
scheme = url.scheme
|
||||
if scheme == 'https':
|
||||
return self.ssl_pool_manager
|
||||
else:
|
||||
return self.pool_manager
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
body=None, post_params=None):
|
||||
"""
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param query_params: query parameters in the url
|
||||
:param headers: http request headers
|
||||
:param body: request json body, for `application/json`
|
||||
:param post_params: request post parameters, `application/x-www-form-urlencode`
|
||||
and `multipart/form-data`
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH']
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
body=None, post_params=None):
|
||||
"""
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param query_params: query parameters in the url
|
||||
:param headers: http request headers
|
||||
:param body: request json body, for `application/json`
|
||||
:param post_params: request post parameters, `application/x-www-form-urlencode`
|
||||
and `multipart/form-data`
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH']
|
||||
|
||||
if post_params and body:
|
||||
raise ValueError("body parameter cannot be used with post_params parameter.")
|
||||
if post_params and body:
|
||||
raise ValueError("body parameter cannot be used with post_params parameter.")
|
||||
|
||||
post_params = post_params or {}
|
||||
headers = headers or {}
|
||||
post_params = post_params or {}
|
||||
headers = headers or {}
|
||||
|
||||
if 'Content-Type' not in headers:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
if 'Content-Type' not in headers:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
# For `POST`, `PUT`, `PATCH`
|
||||
if method in ['POST', 'PUT', 'PATCH']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/json':
|
||||
r = self.agent(url).request(method, url,
|
||||
body=json.dumps(body),
|
||||
headers=headers)
|
||||
if headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=False,
|
||||
headers=headers)
|
||||
if headers['Content-Type'] == 'multipart/form-data':
|
||||
# must del headers['Content-Type'], or the correct Content-Type
|
||||
# which generated by urllib3 will be overwritten.
|
||||
del headers['Content-Type']
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=True,
|
||||
headers=headers)
|
||||
# For `GET`, `HEAD`, `DELETE`
|
||||
else:
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=query_params,
|
||||
headers=headers)
|
||||
r = RESTResponse(r)
|
||||
# For `POST`, `PUT`, `PATCH`
|
||||
if method in ['POST', 'PUT', 'PATCH']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/json':
|
||||
r = self.agent(url).request(method, url,
|
||||
body=json.dumps(body),
|
||||
headers=headers)
|
||||
if headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=False,
|
||||
headers=headers)
|
||||
if headers['Content-Type'] == 'multipart/form-data':
|
||||
# must del headers['Content-Type'], or the correct Content-Type
|
||||
# which generated by urllib3 will be overwritten.
|
||||
del headers['Content-Type']
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=True,
|
||||
headers=headers)
|
||||
# For `GET`, `HEAD`, `DELETE`
|
||||
else:
|
||||
r = self.agent(url).request(method, url,
|
||||
fields=query_params,
|
||||
headers=headers)
|
||||
r = RESTResponse(r)
|
||||
|
||||
if r.status not in range(200, 206):
|
||||
raise ApiException(r)
|
||||
if r.status not in range(200, 206):
|
||||
raise ApiException(r)
|
||||
|
||||
return self.process_response(r)
|
||||
return self.process_response(r)
|
||||
|
||||
def process_response(self, response):
|
||||
# In the python 3, the response.data is bytes.
|
||||
# we need to decode it to string.
|
||||
if sys.version_info > (3,):
|
||||
data = response.data.decode('utf8')
|
||||
else:
|
||||
data = response.data
|
||||
try:
|
||||
resp = json.loads(data)
|
||||
except ValueError:
|
||||
resp = data
|
||||
def process_response(self, response):
|
||||
# In the python 3, the response.data is bytes.
|
||||
# we need to decode it to string.
|
||||
if sys.version_info > (3,):
|
||||
data = response.data.decode('utf8')
|
||||
else:
|
||||
data = response.data
|
||||
try:
|
||||
resp = json.loads(data)
|
||||
except ValueError:
|
||||
resp = data
|
||||
|
||||
return resp
|
||||
return resp
|
||||
|
||||
def GET(self, url, headers=None, query_params=None):
|
||||
return self.request("GET", url, headers=headers, query_params=query_params)
|
||||
def GET(self, url, headers=None, query_params=None):
|
||||
return self.request("GET", url, headers=headers, query_params=query_params)
|
||||
|
||||
def HEAD(self, url, headers=None, query_params=None):
|
||||
return self.request("HEAD", url, headers=headers, query_params=query_params)
|
||||
def HEAD(self, url, headers=None, query_params=None):
|
||||
return self.request("HEAD", url, headers=headers, query_params=query_params)
|
||||
|
||||
def DELETE(self, url, headers=None, query_params=None):
|
||||
return self.request("DELETE", url, headers=headers, query_params=query_params)
|
||||
def DELETE(self, url, headers=None, query_params=None):
|
||||
return self.request("DELETE", url, headers=headers, query_params=query_params)
|
||||
|
||||
def POST(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("POST", url, headers=headers, post_params=post_params, body=body)
|
||||
def POST(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("POST", url, headers=headers, post_params=post_params, body=body)
|
||||
|
||||
def PUT(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("PUT", url, headers=headers, post_params=post_params, body=body)
|
||||
def PUT(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("PUT", url, headers=headers, post_params=post_params, body=body)
|
||||
|
||||
def PATCH(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("PATCH", url, headers=headers, post_params=post_params, body=body)
|
||||
def PATCH(self, url, headers=None, post_params=None, body=None):
|
||||
return self.request("PATCH", url, headers=headers, post_params=post_params, body=body)
|
||||
|
||||
|
||||
class ApiException(Exception):
|
||||
"""
|
||||
Non-2xx HTTP response
|
||||
"""
|
||||
"""
|
||||
Non-2xx HTTP response
|
||||
"""
|
||||
|
||||
def __init__(self, http_resp):
|
||||
self.status = http_resp.status
|
||||
self.reason = http_resp.reason
|
||||
self.body = http_resp.data
|
||||
self.headers = http_resp.getheaders()
|
||||
def __init__(self, http_resp):
|
||||
self.status = http_resp.status
|
||||
self.reason = http_resp.reason
|
||||
self.body = http_resp.data
|
||||
self.headers = http_resp.getheaders()
|
||||
|
||||
# In the python 3, the self.body is bytes.
|
||||
# we need to decode it to string.
|
||||
if sys.version_info > (3,):
|
||||
data = self.body.decode('utf8')
|
||||
else:
|
||||
data = self.body
|
||||
|
||||
try:
|
||||
self.body = json.loads(data)
|
||||
except ValueError:
|
||||
self.body = data
|
||||
# In the python 3, the self.body is bytes.
|
||||
# we need to decode it to string.
|
||||
if sys.version_info > (3,):
|
||||
data = self.body.decode('utf8')
|
||||
else:
|
||||
data = self.body
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Custom error response messages
|
||||
"""
|
||||
return "({0})\n"\
|
||||
"Reason: {1}\n"\
|
||||
"HTTP response headers: {2}\n"\
|
||||
"HTTP response body: {3}\n".\
|
||||
format(self.status, self.reason, self.headers, self.body)
|
||||
try:
|
||||
self.body = json.loads(data)
|
||||
except ValueError:
|
||||
self.body = data
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Custom error response messages
|
||||
"""
|
||||
return "({0})\n"\
|
||||
"Reason: {1}\n"\
|
||||
"HTTP response headers: {2}\n"\
|
||||
"HTTP response body: {3}\n".\
|
||||
format(self.status, self.reason, self.headers, self.body)
|
||||
|
||||
class RESTClient(object):
|
||||
"""
|
||||
A class with all class methods to perform JSON requests.
|
||||
"""
|
||||
"""
|
||||
A class with all class methods to perform JSON requests.
|
||||
"""
|
||||
|
||||
IMPL = RESTClientObject()
|
||||
IMPL = RESTClientObject()
|
||||
|
||||
@classmethod
|
||||
def request(cls, *n, **kw):
|
||||
"""
|
||||
Perform a REST request and parse the response.
|
||||
"""
|
||||
return cls.IMPL.request(*n, **kw)
|
||||
@classmethod
|
||||
def request(cls, *n, **kw):
|
||||
"""
|
||||
Perform a REST request and parse the response.
|
||||
"""
|
||||
return cls.IMPL.request(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def GET(cls, *n, **kw):
|
||||
"""
|
||||
Perform a GET request using `RESTClient.request()`.
|
||||
"""
|
||||
return cls.IMPL.GET(*n, **kw)
|
||||
@classmethod
|
||||
def GET(cls, *n, **kw):
|
||||
"""
|
||||
Perform a GET request using `RESTClient.request()`.
|
||||
"""
|
||||
return cls.IMPL.GET(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def HEAD(cls, *n, **kw):
|
||||
"""
|
||||
Perform a HEAD request using `RESTClient.request()`.
|
||||
"""
|
||||
return cls.IMPL.GET(*n, **kw)
|
||||
@classmethod
|
||||
def HEAD(cls, *n, **kw):
|
||||
"""
|
||||
Perform a HEAD request using `RESTClient.request()`.
|
||||
"""
|
||||
return cls.IMPL.GET(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def POST(cls, *n, **kw):
|
||||
"""
|
||||
Perform a POST request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.POST(*n, **kw)
|
||||
@classmethod
|
||||
def POST(cls, *n, **kw):
|
||||
"""
|
||||
Perform a POST request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.POST(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def PUT(cls, *n, **kw):
|
||||
"""
|
||||
Perform a PUT request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.PUT(*n, **kw)
|
||||
@classmethod
|
||||
def PUT(cls, *n, **kw):
|
||||
"""
|
||||
Perform a PUT request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.PUT(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def PATCH(cls, *n, **kw):
|
||||
"""
|
||||
Perform a PATCH request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.PATCH(*n, **kw)
|
||||
@classmethod
|
||||
def PATCH(cls, *n, **kw):
|
||||
"""
|
||||
Perform a PATCH request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.PATCH(*n, **kw)
|
||||
|
||||
@classmethod
|
||||
def DELETE(cls, *n, **kw):
|
||||
"""
|
||||
Perform a DELETE request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.DELETE(*n, **kw)
|
||||
@classmethod
|
||||
def DELETE(cls, *n, **kw):
|
||||
"""
|
||||
Perform a DELETE request using `RESTClient.request()`
|
||||
"""
|
||||
return cls.IMPL.DELETE(*n, **kw)
|
||||
|
||||
@@ -3,18 +3,18 @@ from setuptools import setup, find_packages
|
||||
|
||||
|
||||
|
||||
# To install the library, open a Terminal shell, then run this
|
||||
# file by typing:
|
||||
#
|
||||
# python setup.py install
|
||||
#
|
||||
# You need to have the setuptools module installed.
|
||||
# Try reading the setuptools documentation:
|
||||
# http://pypi.python.org/pypi/setuptools
|
||||
# To install the library, open a Terminal shell, then run this
|
||||
# file by typing:
|
||||
#
|
||||
# python setup.py install
|
||||
#
|
||||
# You need to have the setuptools module installed.
|
||||
# Try reading the setuptools documentation:
|
||||
# http://pypi.python.org/pypi/setuptools
|
||||
|
||||
REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi"]
|
||||
REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi"]
|
||||
|
||||
setup(
|
||||
setup(
|
||||
name="SwaggerPetstore",
|
||||
version="1.0.0",
|
||||
description="Swagger Petstore",
|
||||
@@ -27,7 +27,7 @@ setup(
|
||||
long_description="""\
|
||||
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user