weheat 2025.1.14__py3-none-any.whl → 2025.1.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of weheat might be problematic. Click here for more details.

weheat/api/user_api.py CHANGED
@@ -12,27 +12,28 @@
12
12
  """ # noqa: E501
13
13
 
14
14
 
15
- import re # noqa: F401
16
15
  import io
17
16
  import warnings
18
17
 
18
+ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
19
+ from typing import Dict, List, Optional, Tuple, Union, Any
20
+
19
21
  try:
20
- from pydantic.v1 import validate_arguments, Field, StrictStr
22
+ from typing import Annotated
21
23
  except ImportError:
22
- from pydantic import validate_arguments, Field, StrictStr
24
+ from typing_extensions import Annotated
23
25
 
26
+ from pydantic import Field
24
27
  from typing_extensions import Annotated
28
+ from pydantic import StrictStr
25
29
 
26
30
  from typing import Optional
27
31
 
28
- from weheat.models.read_user_dto import ReadUserDto
32
+ from weheat.models.read_user_me_dto import ReadUserMeDto
29
33
 
30
34
  from weheat.api_client import ApiClient
31
35
  from weheat.api_response import ApiResponse
32
- from weheat.exceptions import ( # noqa: F401
33
- ApiTypeError,
34
- ApiValueError
35
- )
36
+ from weheat.rest import RESTResponseType
36
37
 
37
38
 
38
39
  class UserApi:
@@ -47,147 +48,274 @@ class UserApi:
47
48
  api_client = ApiClient.get_default()
48
49
  self.api_client = api_client
49
50
 
50
- @validate_arguments
51
- def api_v1_users_me_get(self, x_version : Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None, **kwargs) -> ReadUserDto: # noqa: E501
52
- """Me endpoint to verify everything is ok after login (also sets Name of user after registration) Please always call this after login so backend (and frontend) can verify everything is correct. # noqa: E501
53
-
54
- This method makes a synchronous HTTP request by default. To make an
55
- asynchronous HTTP request, please pass async_req=True
51
+ @validate_call
52
+ async def api_v1_users_me_get(
53
+ self,
54
+ x_version: Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None,
55
+ _request_timeout: Union[
56
+ None,
57
+ Annotated[StrictFloat, Field(gt=0)],
58
+ Tuple[
59
+ Annotated[StrictFloat, Field(gt=0)],
60
+ Annotated[StrictFloat, Field(gt=0)]
61
+ ]
62
+ ] = None,
63
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
64
+ _content_type: Optional[StrictStr] = None,
65
+ _headers: Optional[Dict[StrictStr, Any]] = None,
66
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
67
+ ) -> ReadUserMeDto:
68
+ """Me endpoint to verify everything is ok after login (also sets Name of user after registration) Please always call this after login so backend (and frontend) can verify everything is correct.
56
69
 
57
- >>> thread = api.api_v1_users_me_get(x_version, async_req=True)
58
- >>> result = thread.get()
59
70
 
60
71
  :param x_version: Optional version parameter for frontend applications to check if an update / refresh is needed
61
72
  :type x_version: str
62
- :param async_req: Whether to execute the request asynchronously.
63
- :type async_req: bool, optional
64
- :param _request_timeout: timeout setting for this request.
65
- If one number provided, it will be total request
66
- timeout. It can also be a pair (tuple) of
67
- (connection, read) timeouts.
73
+ :param _request_timeout: timeout setting for this request. If one
74
+ number provided, it will be total request
75
+ timeout. It can also be a pair (tuple) of
76
+ (connection, read) timeouts.
77
+ :type _request_timeout: int, tuple(int, int), optional
78
+ :param _request_auth: set to override the auth_settings for an a single
79
+ request; this effectively ignores the
80
+ authentication in the spec for a single request.
81
+ :type _request_auth: dict, optional
82
+ :param _content_type: force content-type for the request.
83
+ :type _content_type: str, Optional
84
+ :param _headers: set to override the headers for a single
85
+ request; this effectively ignores the headers
86
+ in the spec for a single request.
87
+ :type _headers: dict, optional
88
+ :param _host_index: set to override the host_index for a single
89
+ request; this effectively ignores the host_index
90
+ in the spec for a single request.
91
+ :type _host_index: int, optional
68
92
  :return: Returns the result object.
69
- If the method is called asynchronously,
70
- returns the request thread.
71
- :rtype: ReadUserDto
72
- """
73
- kwargs['_return_http_data_only'] = True
74
- if '_preload_content' in kwargs:
75
- message = "Error! Please call the api_v1_users_me_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
76
- raise ValueError(message)
77
- return self.api_v1_users_me_get_with_http_info(x_version, **kwargs) # noqa: E501
78
-
79
- @validate_arguments
80
- def api_v1_users_me_get_with_http_info(self, x_version : Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None, **kwargs) -> ApiResponse: # noqa: E501
81
- """Me endpoint to verify everything is ok after login (also sets Name of user after registration) Please always call this after login so backend (and frontend) can verify everything is correct. # noqa: E501
82
-
83
- This method makes a synchronous HTTP request by default. To make an
84
- asynchronous HTTP request, please pass async_req=True
85
-
86
- >>> thread = api.api_v1_users_me_get_with_http_info(x_version, async_req=True)
87
- >>> result = thread.get()
93
+ """ # noqa: E501
94
+
95
+ _param = self._api_v1_users_me_get_serialize(
96
+ x_version=x_version,
97
+ _request_auth=_request_auth,
98
+ _content_type=_content_type,
99
+ _headers=_headers,
100
+ _host_index=_host_index
101
+ )
102
+
103
+ _response_types_map: Dict[str, Optional[str]] = {
104
+ '403': "str",
105
+ '500': None,
106
+ '505': None,
107
+ '200': "ReadUserMeDto",
108
+ '400': None,
109
+ '404': None,
110
+ '409': None,
111
+ }
112
+ response_data = await self.api_client.call_api(
113
+ *_param,
114
+ _request_timeout=_request_timeout
115
+ )
116
+ await response_data.read()
117
+ return self.api_client.response_deserialize(
118
+ response_data=response_data,
119
+ response_types_map=_response_types_map,
120
+ ).data
121
+
122
+
123
+ @validate_call
124
+ async def api_v1_users_me_get_with_http_info(
125
+ self,
126
+ x_version: Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None,
127
+ _request_timeout: Union[
128
+ None,
129
+ Annotated[StrictFloat, Field(gt=0)],
130
+ Tuple[
131
+ Annotated[StrictFloat, Field(gt=0)],
132
+ Annotated[StrictFloat, Field(gt=0)]
133
+ ]
134
+ ] = None,
135
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
136
+ _content_type: Optional[StrictStr] = None,
137
+ _headers: Optional[Dict[StrictStr, Any]] = None,
138
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
139
+ ) -> ApiResponse[ReadUserMeDto]:
140
+ """Me endpoint to verify everything is ok after login (also sets Name of user after registration) Please always call this after login so backend (and frontend) can verify everything is correct.
141
+
88
142
 
89
143
  :param x_version: Optional version parameter for frontend applications to check if an update / refresh is needed
90
144
  :type x_version: str
91
- :param async_req: Whether to execute the request asynchronously.
92
- :type async_req: bool, optional
93
- :param _preload_content: if False, the ApiResponse.data will
94
- be set to none and raw_data will store the
95
- HTTP response body without reading/decoding.
96
- Default is True.
97
- :type _preload_content: bool, optional
98
- :param _return_http_data_only: response data instead of ApiResponse
99
- object with status code, headers, etc
100
- :type _return_http_data_only: bool, optional
101
145
  :param _request_timeout: timeout setting for this request. If one
102
146
  number provided, it will be total request
103
147
  timeout. It can also be a pair (tuple) of
104
148
  (connection, read) timeouts.
149
+ :type _request_timeout: int, tuple(int, int), optional
105
150
  :param _request_auth: set to override the auth_settings for an a single
106
- request; this effectively ignores the authentication
107
- in the spec for a single request.
151
+ request; this effectively ignores the
152
+ authentication in the spec for a single request.
108
153
  :type _request_auth: dict, optional
109
- :type _content_type: string, optional: force content-type for the request
154
+ :param _content_type: force content-type for the request.
155
+ :type _content_type: str, Optional
156
+ :param _headers: set to override the headers for a single
157
+ request; this effectively ignores the headers
158
+ in the spec for a single request.
159
+ :type _headers: dict, optional
160
+ :param _host_index: set to override the host_index for a single
161
+ request; this effectively ignores the host_index
162
+ in the spec for a single request.
163
+ :type _host_index: int, optional
110
164
  :return: Returns the result object.
111
- If the method is called asynchronously,
112
- returns the request thread.
113
- :rtype: tuple(ReadUserDto, status_code(int), headers(HTTPHeaderDict))
114
- """
165
+ """ # noqa: E501
166
+
167
+ _param = self._api_v1_users_me_get_serialize(
168
+ x_version=x_version,
169
+ _request_auth=_request_auth,
170
+ _content_type=_content_type,
171
+ _headers=_headers,
172
+ _host_index=_host_index
173
+ )
174
+
175
+ _response_types_map: Dict[str, Optional[str]] = {
176
+ '403': "str",
177
+ '500': None,
178
+ '505': None,
179
+ '200': "ReadUserMeDto",
180
+ '400': None,
181
+ '404': None,
182
+ '409': None,
183
+ }
184
+ response_data = await self.api_client.call_api(
185
+ *_param,
186
+ _request_timeout=_request_timeout
187
+ )
188
+ await response_data.read()
189
+ return self.api_client.response_deserialize(
190
+ response_data=response_data,
191
+ response_types_map=_response_types_map,
192
+ )
115
193
 
116
- _params = locals()
117
194
 
118
- _all_params = [
119
- 'x_version'
120
- ]
121
- _all_params.extend(
122
- [
123
- 'async_req',
124
- '_return_http_data_only',
125
- '_preload_content',
126
- '_request_timeout',
127
- '_request_auth',
128
- '_content_type',
129
- '_headers'
195
+ @validate_call
196
+ async def api_v1_users_me_get_without_preload_content(
197
+ self,
198
+ x_version: Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None,
199
+ _request_timeout: Union[
200
+ None,
201
+ Annotated[StrictFloat, Field(gt=0)],
202
+ Tuple[
203
+ Annotated[StrictFloat, Field(gt=0)],
204
+ Annotated[StrictFloat, Field(gt=0)]
130
205
  ]
206
+ ] = None,
207
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
208
+ _content_type: Optional[StrictStr] = None,
209
+ _headers: Optional[Dict[StrictStr, Any]] = None,
210
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
211
+ ) -> RESTResponseType:
212
+ """Me endpoint to verify everything is ok after login (also sets Name of user after registration) Please always call this after login so backend (and frontend) can verify everything is correct.
213
+
214
+
215
+ :param x_version: Optional version parameter for frontend applications to check if an update / refresh is needed
216
+ :type x_version: str
217
+ :param _request_timeout: timeout setting for this request. If one
218
+ number provided, it will be total request
219
+ timeout. It can also be a pair (tuple) of
220
+ (connection, read) timeouts.
221
+ :type _request_timeout: int, tuple(int, int), optional
222
+ :param _request_auth: set to override the auth_settings for an a single
223
+ request; this effectively ignores the
224
+ authentication in the spec for a single request.
225
+ :type _request_auth: dict, optional
226
+ :param _content_type: force content-type for the request.
227
+ :type _content_type: str, Optional
228
+ :param _headers: set to override the headers for a single
229
+ request; this effectively ignores the headers
230
+ in the spec for a single request.
231
+ :type _headers: dict, optional
232
+ :param _host_index: set to override the host_index for a single
233
+ request; this effectively ignores the host_index
234
+ in the spec for a single request.
235
+ :type _host_index: int, optional
236
+ :return: Returns the result object.
237
+ """ # noqa: E501
238
+
239
+ _param = self._api_v1_users_me_get_serialize(
240
+ x_version=x_version,
241
+ _request_auth=_request_auth,
242
+ _content_type=_content_type,
243
+ _headers=_headers,
244
+ _host_index=_host_index
245
+ )
246
+
247
+ _response_types_map: Dict[str, Optional[str]] = {
248
+ '403': "str",
249
+ '500': None,
250
+ '505': None,
251
+ '200': "ReadUserMeDto",
252
+ '400': None,
253
+ '404': None,
254
+ '409': None,
255
+ }
256
+ response_data = await self.api_client.call_api(
257
+ *_param,
258
+ _request_timeout=_request_timeout
131
259
  )
260
+ return response_data.response
132
261
 
133
- # validate the arguments
134
- for _key, _val in _params['kwargs'].items():
135
- if _key not in _all_params:
136
- raise ApiTypeError(
137
- "Got an unexpected keyword argument '%s'"
138
- " to method api_v1_users_me_get" % _key
139
- )
140
- _params[_key] = _val
141
- del _params['kwargs']
142
262
 
143
- _collection_formats = {}
263
+ def _api_v1_users_me_get_serialize(
264
+ self,
265
+ x_version,
266
+ _request_auth,
267
+ _content_type,
268
+ _headers,
269
+ _host_index,
270
+ ) -> Tuple:
144
271
 
145
- # process the path parameters
146
- _path_params = {}
272
+ _host = None
273
+
274
+ _collection_formats: Dict[str, str] = {
275
+ }
276
+
277
+ _path_params: Dict[str, str] = {}
278
+ _query_params: List[Tuple[str, str]] = []
279
+ _header_params: Dict[str, Optional[str]] = _headers or {}
280
+ _form_params: List[Tuple[str, str]] = []
281
+ _files: Dict[str, str] = {}
282
+ _body_params: Optional[bytes] = None
147
283
 
284
+ # process the path parameters
148
285
  # process the query parameters
149
- _query_params = []
150
286
  # process the header parameters
151
- _header_params = dict(_params.get('_headers', {}))
152
- if _params['x_version'] is not None:
153
- _header_params['x-version'] = _params['x_version']
154
-
287
+ if x_version is not None:
288
+ _header_params['x-version'] = x_version
155
289
  # process the form parameters
156
- _form_params = []
157
- _files = {}
158
290
  # process the body parameter
159
- _body_params = None
291
+
292
+
160
293
  # set the HTTP header `Accept`
161
294
  _header_params['Accept'] = self.api_client.select_header_accept(
162
- ['text/plain', 'application/json', 'text/json']) # noqa: E501
295
+ [
296
+ 'text/plain',
297
+ 'application/json',
298
+ 'text/json'
299
+ ]
300
+ )
163
301
 
164
- # authentication setting
165
- _auth_settings = ['oauth2'] # noqa: E501
166
302
 
167
- _response_types_map = {
168
- '403': "str",
169
- '505': None,
170
- '200': "ReadUserDto",
171
- '400': None,
172
- '404': None,
173
- '409': None,
174
- '500': None,
175
- }
303
+ # authentication setting
304
+ _auth_settings: List[str] = [
305
+ 'oauth2'
306
+ ]
176
307
 
177
- return self.api_client.call_api(
178
- '/api/v1/users/me', 'GET',
179
- _path_params,
180
- _query_params,
181
- _header_params,
308
+ return self.api_client.param_serialize(
309
+ method='GET',
310
+ resource_path='/api/v1/users/me',
311
+ path_params=_path_params,
312
+ query_params=_query_params,
313
+ header_params=_header_params,
182
314
  body=_body_params,
183
315
  post_params=_form_params,
184
316
  files=_files,
185
- response_types_map=_response_types_map,
186
317
  auth_settings=_auth_settings,
187
- async_req=_params.get('async_req'),
188
- _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
189
- _preload_content=_params.get('_preload_content', True),
190
- _request_timeout=_params.get('_request_timeout'),
191
318
  collection_formats=_collection_formats,
192
- _request_auth=_params.get('_request_auth'))
193
-
319
+ _host=_host,
320
+ _request_auth=_request_auth
321
+ )