Skip to content

Commit

Permalink
rerun bin/python-*.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed May 9, 2018
1 parent e4e758e commit 31e69f8
Show file tree
Hide file tree
Showing 30 changed files with 774 additions and 180 deletions.
1 change: 1 addition & 0 deletions samples/client/petstore/python-asyncio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
*FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
*FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/python-asyncio/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_string** | **str** | | [optional]
**enum_string_required** | **str** | |
**enum_integer** | **int** | | [optional]
**enum_number** | **float** | | [optional]
**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional]
Expand Down
59 changes: 53 additions & 6 deletions samples/client/petstore/python-asyncio/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Method | HTTP request | Description
[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
Expand Down Expand Up @@ -203,6 +204,52 @@ No authorization required

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **test_body_with_query_params**
> test_body_with_query_params(body, query)


### Example
```python
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.User() # User |
query = 'query_example' # str |

try:
api_instance.test_body_with_query_params(body, query)
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**User**](User.md)| |
**query** | **str**| |

### Return type

void (empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **test_client_model**
> Client test_client_model(body)
Expand Down Expand Up @@ -252,7 +299,7 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **test_endpoint_parameters**
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, _float=_float, string=string, binary=binary, _date=_date, date_time=date_time, password=password, param_callback=param_callback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Expand Down Expand Up @@ -280,17 +327,17 @@ byte = 'B' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 789 # int | None (optional)
float = 3.4 # float | None (optional)
_float = 3.4 # float | None (optional)
string = 'string_example' # str | None (optional)
binary = 'B' # str | None (optional)
date = '2013-10-20' # date | None (optional)
_date = '2013-10-20' # date | None (optional)
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)

try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, _float=_float, string=string, binary=binary, _date=_date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
Expand All @@ -306,10 +353,10 @@ Name | Type | Description | Notes
**integer** | **int**| None | [optional]
**int32** | **int**| None | [optional]
**int64** | **int**| None | [optional]
**float** | **float**| None | [optional]
**_float** | **float**| None | [optional]
**string** | **str**| None | [optional]
**binary** | **str**| None | [optional]
**date** | **date**| None | [optional]
**_date** | **date**| None | [optional]
**date_time** | **datetime**| None | [optional]
**password** | **str**| None | [optional]
**param_callback** | **str**| None | [optional]
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/python-asyncio/docs/FormatTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Name | Type | Description | Notes
**int32** | **int** | | [optional]
**int64** | **int** | | [optional]
**number** | **float** | |
**float** | **float** | | [optional]
**_float** | **float** | | [optional]
**double** | **float** | | [optional]
**string** | **str** | | [optional]
**byte** | **str** | |
**binary** | **str** | | [optional]
**date** | **date** | |
**_date** | **date** | |
**date_time** | **datetime** | | [optional]
**uuid** | **str** | | [optional]
**password** | **str** | |
Expand Down
123 changes: 112 additions & 11 deletions samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,107 @@ def fake_outer_string_serialize_with_http_info(self, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def test_body_with_query_params(self, body, query, **kwargs): # noqa: E501
"""test_body_with_query_params # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_body_with_query_params(body, query, async=True)
>>> result = thread.get()
:param async bool
:param User body: (required)
:param str query: (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.test_body_with_query_params_with_http_info(body, query, **kwargs) # noqa: E501
else:
(data) = self.test_body_with_query_params_with_http_info(body, query, **kwargs) # noqa: E501
return data

def test_body_with_query_params_with_http_info(self, body, query, **kwargs): # noqa: E501
"""test_body_with_query_params # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_body_with_query_params_with_http_info(body, query, async=True)
>>> result = thread.get()
:param async bool
:param User body: (required)
:param str query: (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['body', 'query'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method test_body_with_query_params" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'body' is set
if ('body' not in params or
params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_body_with_query_params`") # noqa: E501
# verify the required parameter 'query' is set
if ('query' not in params or
params['query'] is None):
raise ValueError("Missing the required parameter `query` when calling `test_body_with_query_params`") # noqa: E501

collection_formats = {}

path_params = {}

query_params = []
if 'query' in params:
query_params.append(('query', params['query'])) # noqa: E501

header_params = {}

form_params = []
local_var_files = {}

body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501

# Authentication setting
auth_settings = [] # noqa: E501

return self.api_client.call_api(
'/fake/body-with-query-params', 'PUT',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
auth_settings=auth_settings,
async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def test_client_model(self, body, **kwargs): # noqa: E501
"""To test \"client\" model # noqa: E501
Expand Down Expand Up @@ -497,10 +598,10 @@ def test_endpoint_parameters(self, number, double, pattern_without_delimiter, by
:param int integer: None
:param int int32: None
:param int int64: None
:param float float: None
:param float _float: None
:param str string: None
:param str binary: None
:param date date: None
:param date _date: None
:param datetime date_time: None
:param str password: None
:param str param_callback: None
Expand Down Expand Up @@ -532,10 +633,10 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou
:param int integer: None
:param int int32: None
:param int int64: None
:param float float: None
:param float _float: None
:param str string: None
:param str binary: None
:param date date: None
:param date _date: None
:param datetime date_time: None
:param str password: None
:param str param_callback: None
Expand All @@ -544,7 +645,7 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou
returns the request thread.
"""

all_params = ['number', 'double', 'pattern_without_delimiter', 'byte', 'integer', 'int32', 'int64', 'float', 'string', 'binary', 'date', 'date_time', 'password', 'param_callback'] # noqa: E501
all_params = ['number', 'double', 'pattern_without_delimiter', 'byte', 'integer', 'int32', 'int64', '_float', 'string', 'binary', '_date', 'date_time', 'password', 'param_callback'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
Expand Down Expand Up @@ -594,8 +695,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to `200`") # noqa: E501
if 'int32' in params and params['int32'] < 20: # noqa: E501
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20`") # noqa: E501
if 'float' in params and params['float'] > 987.6: # noqa: E501
raise ValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`") # noqa: E501
if '_float' in params and params['_float'] > 987.6: # noqa: E501
raise ValueError("Invalid value for parameter `_float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`") # noqa: E501
if 'string' in params and not re.search('[a-z]', params['string'], flags=re.IGNORECASE): # noqa: E501
raise ValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`") # noqa: E501
if ('password' in params and
Expand All @@ -622,8 +723,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou
form_params.append(('int64', params['int64'])) # noqa: E501
if 'number' in params:
form_params.append(('number', params['number'])) # noqa: E501
if 'float' in params:
form_params.append(('float', params['float'])) # noqa: E501
if '_float' in params:
form_params.append(('float', params['_float'])) # noqa: E501
if 'double' in params:
form_params.append(('double', params['double'])) # noqa: E501
if 'string' in params:
Expand All @@ -634,8 +735,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou
form_params.append(('byte', params['byte'])) # noqa: E501
if 'binary' in params:
form_params.append(('binary', params['binary'])) # noqa: E501
if 'date' in params:
form_params.append(('date', params['date'])) # noqa: E501
if '_date' in params:
form_params.append(('date', params['_date'])) # noqa: E501
if 'date_time' in params:
form_params.append(('dateTime', params['date_time'])) # noqa: E501
if 'password' in params:
Expand Down
23 changes: 19 additions & 4 deletions samples/client/petstore/python-asyncio/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ApiClient(object):
the API.
:param cookie: a cookie to include in the header when making calls
to the API
:param pool_threads: The number of threads to use for async requests
to the API. More threads means more concurrent API requests.
"""

PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
Expand All @@ -59,14 +61,15 @@ class ApiClient(object):
'datetime': datetime.datetime,
'object': object,
}
_pool = None

def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None):
cookie=None, pool_threads=1):
if configuration is None:
configuration = Configuration()
self.configuration = configuration
self.pool_threads = pool_threads

self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
Expand All @@ -76,8 +79,20 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.user_agent = 'Swagger-Codegen/1.0.0/python'

def __del__(self):
self.pool.close()
self.pool.join()
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None

@property
def pool(self):
"""Create thread pool on first request
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
self._pool = ThreadPool(self.pool_threads)
return self._pool

@property
def user_agent(self):
Expand Down
Loading

0 comments on commit 31e69f8

Please sign in to comment.