Skip to content

Commit 45a842e

Browse files
committed
Upgrade swagger version and use cursor object
1 parent ef9b874 commit 45a842e

35 files changed

Lines changed: 234 additions & 150 deletions

docs/DraftsRead.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**cursor** | **object** | Information about paginated results | [optional]
6+
**cursor** | [**Cursor**](Cursor.md) | | [optional]
77
**data** | [**list[DraftMetaRead]**](DraftMetaRead.md) | A list of draft metadata objects | [optional]
88

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

dyspatch_client/api/drafts_api.py

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

dyspatch_client/api/localizations_api.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ def localizations_localization_id_get(self, localization_id, target_language, **
3838
3939
Returns a specific localization object with a matching ID. # noqa: E501
4040
This method makes a synchronous HTTP request by default. To make an
41-
asynchronous HTTP request, please pass async=True
42-
>>> thread = api.localizations_localization_id_get(localization_id, target_language, async=True)
41+
asynchronous HTTP request, please pass async_req=True
42+
>>> thread = api.localizations_localization_id_get(localization_id, target_language, async_req=True)
4343
>>> result = thread.get()
4444
45-
:param async bool
45+
:param async_req bool
4646
:param str localization_id: A localization ID (required)
4747
:param str target_language: The type of templating language to compile as. Should only be used for visual templates. (required)
4848
:return: LocalizationRead
4949
If the method is called asynchronously,
5050
returns the request thread.
5151
"""
5252
kwargs['_return_http_data_only'] = True
53-
if kwargs.get('async'):
53+
if kwargs.get('async_req'):
5454
return self.localizations_localization_id_get_with_http_info(localization_id, target_language, **kwargs) # noqa: E501
5555
else:
5656
(data) = self.localizations_localization_id_get_with_http_info(localization_id, target_language, **kwargs) # noqa: E501
@@ -61,11 +61,11 @@ def localizations_localization_id_get_with_http_info(self, localization_id, targ
6161
6262
Returns a specific localization object with a matching ID. # noqa: E501
6363
This method makes a synchronous HTTP request by default. To make an
64-
asynchronous HTTP request, please pass async=True
65-
>>> thread = api.localizations_localization_id_get_with_http_info(localization_id, target_language, async=True)
64+
asynchronous HTTP request, please pass async_req=True
65+
>>> thread = api.localizations_localization_id_get_with_http_info(localization_id, target_language, async_req=True)
6666
>>> result = thread.get()
6767
68-
:param async bool
68+
:param async_req bool
6969
:param str localization_id: A localization ID (required)
7070
:param str target_language: The type of templating language to compile as. Should only be used for visual templates. (required)
7171
:return: LocalizationRead
@@ -74,7 +74,7 @@ def localizations_localization_id_get_with_http_info(self, localization_id, targ
7474
"""
7575

7676
all_params = ['localization_id', 'target_language'] # noqa: E501
77-
all_params.append('async')
77+
all_params.append('async_req')
7878
all_params.append('_return_http_data_only')
7979
all_params.append('_preload_content')
8080
all_params.append('_request_timeout')
@@ -130,7 +130,7 @@ def localizations_localization_id_get_with_http_info(self, localization_id, targ
130130
files=local_var_files,
131131
response_type='LocalizationRead', # noqa: E501
132132
auth_settings=auth_settings,
133-
async=params.get('async'),
133+
async_req=params.get('async_req'),
134134
_return_http_data_only=params.get('_return_http_data_only'),
135135
_preload_content=params.get('_preload_content', True),
136136
_request_timeout=params.get('_request_timeout'),

dyspatch_client/api/templates_api.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ def templates_get(self, **kwargs): # noqa: E501
3838
3939
Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated. # noqa: E501
4040
This method makes a synchronous HTTP request by default. To make an
41-
asynchronous HTTP request, please pass async=True
42-
>>> thread = api.templates_get(async=True)
41+
asynchronous HTTP request, please pass async_req=True
42+
>>> thread = api.templates_get(async_req=True)
4343
>>> result = thread.get()
4444
45-
:param async bool
45+
:param async_req bool
4646
:param str cursor: A cursor value used to retrieve a specific page from a paginated result set.
4747
:return: TemplatesRead
4848
If the method is called asynchronously,
4949
returns the request thread.
5050
"""
5151
kwargs['_return_http_data_only'] = True
52-
if kwargs.get('async'):
52+
if kwargs.get('async_req'):
5353
return self.templates_get_with_http_info(**kwargs) # noqa: E501
5454
else:
5555
(data) = self.templates_get_with_http_info(**kwargs) # noqa: E501
@@ -60,19 +60,19 @@ def templates_get_with_http_info(self, **kwargs): # noqa: E501
6060
6161
Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated. # noqa: E501
6262
This method makes a synchronous HTTP request by default. To make an
63-
asynchronous HTTP request, please pass async=True
64-
>>> thread = api.templates_get_with_http_info(async=True)
63+
asynchronous HTTP request, please pass async_req=True
64+
>>> thread = api.templates_get_with_http_info(async_req=True)
6565
>>> result = thread.get()
6666
67-
:param async bool
67+
:param async_req bool
6868
:param str cursor: A cursor value used to retrieve a specific page from a paginated result set.
6969
:return: TemplatesRead
7070
If the method is called asynchronously,
7171
returns the request thread.
7272
"""
7373

7474
all_params = ['cursor'] # noqa: E501
75-
all_params.append('async')
75+
all_params.append('async_req')
7676
all_params.append('_return_http_data_only')
7777
all_params.append('_preload_content')
7878
all_params.append('_request_timeout')
@@ -118,7 +118,7 @@ def templates_get_with_http_info(self, **kwargs): # noqa: E501
118118
files=local_var_files,
119119
response_type='TemplatesRead', # noqa: E501
120120
auth_settings=auth_settings,
121-
async=params.get('async'),
121+
async_req=params.get('async_req'),
122122
_return_http_data_only=params.get('_return_http_data_only'),
123123
_preload_content=params.get('_preload_content', True),
124124
_request_timeout=params.get('_request_timeout'),
@@ -129,19 +129,19 @@ def templates_template_id_get(self, template_id, target_language, **kwargs): #
129129
130130
Gets a template object with the matching ID. If the template has published content the \"compiled\" field will contain the template . # noqa: E501
131131
This method makes a synchronous HTTP request by default. To make an
132-
asynchronous HTTP request, please pass async=True
133-
>>> thread = api.templates_template_id_get(template_id, target_language, async=True)
132+
asynchronous HTTP request, please pass async_req=True
133+
>>> thread = api.templates_template_id_get(template_id, target_language, async_req=True)
134134
>>> result = thread.get()
135135
136-
:param async bool
136+
:param async_req bool
137137
:param str template_id: A template ID (required)
138138
:param str target_language: The type of templating language to compile as. Should only be used for visual templates. (required)
139139
:return: TemplateRead
140140
If the method is called asynchronously,
141141
returns the request thread.
142142
"""
143143
kwargs['_return_http_data_only'] = True
144-
if kwargs.get('async'):
144+
if kwargs.get('async_req'):
145145
return self.templates_template_id_get_with_http_info(template_id, target_language, **kwargs) # noqa: E501
146146
else:
147147
(data) = self.templates_template_id_get_with_http_info(template_id, target_language, **kwargs) # noqa: E501
@@ -152,11 +152,11 @@ def templates_template_id_get_with_http_info(self, template_id, target_language,
152152
153153
Gets a template object with the matching ID. If the template has published content the \"compiled\" field will contain the template . # noqa: E501
154154
This method makes a synchronous HTTP request by default. To make an
155-
asynchronous HTTP request, please pass async=True
156-
>>> thread = api.templates_template_id_get_with_http_info(template_id, target_language, async=True)
155+
asynchronous HTTP request, please pass async_req=True
156+
>>> thread = api.templates_template_id_get_with_http_info(template_id, target_language, async_req=True)
157157
>>> result = thread.get()
158158
159-
:param async bool
159+
:param async_req bool
160160
:param str template_id: A template ID (required)
161161
:param str target_language: The type of templating language to compile as. Should only be used for visual templates. (required)
162162
:return: TemplateRead
@@ -165,7 +165,7 @@ def templates_template_id_get_with_http_info(self, template_id, target_language,
165165
"""
166166

167167
all_params = ['template_id', 'target_language'] # noqa: E501
168-
all_params.append('async')
168+
all_params.append('async_req')
169169
all_params.append('_return_http_data_only')
170170
all_params.append('_preload_content')
171171
all_params.append('_request_timeout')
@@ -221,7 +221,7 @@ def templates_template_id_get_with_http_info(self, template_id, target_language,
221221
files=local_var_files,
222222
response_type='TemplateRead', # noqa: E501
223223
auth_settings=auth_settings,
224-
async=params.get('async'),
224+
async_req=params.get('async_req'),
225225
_return_http_data_only=params.get('_return_http_data_only'),
226226
_preload_content=params.get('_preload_content', True),
227227
_request_timeout=params.get('_request_timeout'),

dyspatch_client/api_client.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
6666
configuration = Configuration()
6767
self.configuration = configuration
6868

69-
self.pool = ThreadPool()
69+
# Use the pool property to lazily initialize the ThreadPool.
70+
self._pool = None
7071
self.rest_client = rest.RESTClientObject(configuration)
7172
self.default_headers = {}
7273
if header_name is not None:
@@ -76,8 +77,15 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7677
self.user_agent = 'Swagger-Codegen/3.0.1/python'
7778

7879
def __del__(self):
79-
self.pool.close()
80-
self.pool.join()
80+
if self._pool is not None:
81+
self._pool.close()
82+
self._pool.join()
83+
84+
@property
85+
def pool(self):
86+
if self._pool is None:
87+
self._pool = ThreadPool()
88+
return self._pool
8189

8290
@property
8391
def user_agent(self):
@@ -274,12 +282,12 @@ def __deserialize(self, data, klass):
274282
def call_api(self, resource_path, method,
275283
path_params=None, query_params=None, header_params=None,
276284
body=None, post_params=None, files=None,
277-
response_type=None, auth_settings=None, async=None,
285+
response_type=None, auth_settings=None, async_req=None,
278286
_return_http_data_only=None, collection_formats=None,
279287
_preload_content=True, _request_timeout=None):
280288
"""Makes the HTTP request (synchronous) and returns deserialized data.
281289
282-
To make an async request, set the async parameter.
290+
To make an async request, set the async_req parameter.
283291
284292
:param resource_path: Path to method endpoint.
285293
:param method: Method to call.
@@ -294,7 +302,7 @@ def call_api(self, resource_path, method,
294302
:param response: Response data type.
295303
:param files dict: key -> filename, value -> filepath,
296304
for `multipart/form-data`.
297-
:param async bool: execute request asynchronously
305+
:param async_req bool: execute request asynchronously
298306
:param _return_http_data_only: response data without head status code
299307
and headers
300308
:param collection_formats: dict of collection formats for path, query,
@@ -307,13 +315,13 @@ def call_api(self, resource_path, method,
307315
timeout. It can also be a pair (tuple) of
308316
(connection, read) timeouts.
309317
:return:
310-
If async parameter is True,
318+
If async_req parameter is True,
311319
the request will be called asynchronously.
312320
The method will return the request thread.
313-
If parameter async is False or missing,
321+
If parameter async_req is False or missing,
314322
then the method will return the response directly.
315323
"""
316-
if not async:
324+
if not async_req:
317325
return self.__call_api(resource_path, method,
318326
path_params, query_params, header_params,
319327
body, post_params, files,
@@ -541,7 +549,7 @@ def __deserialize_primitive(self, data, klass):
541549
try:
542550
return klass(data)
543551
except UnicodeEncodeError:
544-
return six.u(data)
552+
return six.text_type(data)
545553
except TypeError:
546554
return data
547555

@@ -591,6 +599,9 @@ def __deserialize_datatime(self, string):
591599
)
592600
)
593601

602+
def __hasattr(self, object, name):
603+
return name in object.__class__.__dict__
604+
594605
def __deserialize_model(self, data, klass):
595606
"""Deserializes list or dict to model.
596607
@@ -599,7 +610,8 @@ def __deserialize_model(self, data, klass):
599610
:return: model object.
600611
"""
601612

602-
if not klass.swagger_types and not hasattr(klass, 'get_real_child_model'):
613+
if (not klass.swagger_types and
614+
not self.__hasattr(klass, 'get_real_child_model')):
603615
return data
604616

605617
kwargs = {}
@@ -613,7 +625,13 @@ def __deserialize_model(self, data, klass):
613625

614626
instance = klass(**kwargs)
615627

616-
if hasattr(instance, 'get_real_child_model'):
628+
if (isinstance(instance, dict) and
629+
klass.swagger_types is not None and
630+
isinstance(data, dict)):
631+
for key, value in data.items():
632+
if key not in klass.swagger_types:
633+
instance[key] = value
634+
if self.__hasattr(instance, 'get_real_child_model'):
617635
klass_name = instance.get_real_child_model(data)
618636
if klass_name:
619637
instance = self.__deserialize(data, klass_name)

dyspatch_client/configuration.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,22 @@
2323
from six.moves import http_client as httplib
2424

2525

26-
class TypeWithDefault(type):
27-
def __init__(cls, name, bases, dct):
28-
super(TypeWithDefault, cls).__init__(name, bases, dct)
29-
cls._default = None
30-
31-
def __call__(cls):
32-
if cls._default is None:
33-
cls._default = type.__call__(cls)
34-
return copy.copy(cls._default)
35-
36-
def set_default(cls, default):
37-
cls._default = copy.copy(default)
38-
39-
40-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
26+
class Configuration(object):
4127
"""NOTE: This class is auto generated by the swagger code generator program.
4228
4329
Ref: https://github.com/swagger-api/swagger-codegen
4430
Do not edit the class manually.
4531
"""
4632

33+
_default = None
34+
4735
def __init__(self):
4836
"""Constructor"""
37+
if self._default:
38+
for key in self._default.__dict__.keys():
39+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
40+
return
41+
4942
# Default Base url
5043
self.host = "https://api.dyspatch.io"
5144
# Temp file folder for downloading files
@@ -101,6 +94,10 @@ def __init__(self):
10194
# Safe chars for path_param
10295
self.safe_chars_for_path_param = ''
10396

97+
@classmethod
98+
def set_default(cls, default):
99+
cls._default = default
100+
104101
@property
105102
def logger_file(self):
106103
"""The logger file.

dyspatch_client/models/api_error.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def to_dict(self):
153153
))
154154
else:
155155
result[attr] = value
156+
if issubclass(APIError, dict):
157+
for key, value in self.items():
158+
result[key] = value
156159

157160
return result
158161

dyspatch_client/models/body.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def to_dict(self):
8989
))
9090
else:
9191
result[attr] = value
92+
if issubclass(Body, dict):
93+
for key, value in self.items():
94+
result[key] = value
9295

9396
return result
9497

dyspatch_client/models/compiled_read.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ def to_dict(self):
209209
))
210210
else:
211211
result[attr] = value
212+
if issubclass(CompiledRead, dict):
213+
for key, value in self.items():
214+
result[key] = value
212215

213216
return result
214217

dyspatch_client/models/created_at.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def to_dict(self):
6161
))
6262
else:
6363
result[attr] = value
64+
if issubclass(CreatedAt, dict):
65+
for key, value in self.items():
66+
result[key] = value
6467

6568
return result
6669

0 commit comments

Comments
 (0)