hostinger-mail-api 1.0.3__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.
Files changed (59) hide show
  1. hostinger_mail_api/__init__.py +76 -0
  2. hostinger_mail_api/api/__init__.py +10 -0
  3. hostinger_mail_api/api/account_api.py +284 -0
  4. hostinger_mail_api/api/folders_api.py +1271 -0
  5. hostinger_mail_api/api/messages_api.py +4237 -0
  6. hostinger_mail_api/api/quota_api.py +304 -0
  7. hostinger_mail_api/api/send_api.py +336 -0
  8. hostinger_mail_api/api/webhooks_api.py +2154 -0
  9. hostinger_mail_api/api_client.py +795 -0
  10. hostinger_mail_api/api_response.py +21 -0
  11. hostinger_mail_api/configuration.py +579 -0
  12. hostinger_mail_api/exceptions.py +214 -0
  13. hostinger_mail_api/models/__init__.py +54 -0
  14. hostinger_mail_api/models/error.py +89 -0
  15. hostinger_mail_api/models/pagination.py +91 -0
  16. hostinger_mail_api/models/v1_folder_messages_collection.py +99 -0
  17. hostinger_mail_api/models/v1_folder_messages_delete_bulk_request.py +86 -0
  18. hostinger_mail_api/models/v1_folder_messages_flags_bulk_request.py +90 -0
  19. hostinger_mail_api/models/v1_folder_messages_flags_request.py +88 -0
  20. hostinger_mail_api/models/v1_folder_messages_message.py +165 -0
  21. hostinger_mail_api/models/v1_folder_messages_message_address.py +87 -0
  22. hostinger_mail_api/models/v1_folder_messages_message_attachment.py +105 -0
  23. hostinger_mail_api/models/v1_folder_messages_message_text.py +87 -0
  24. hostinger_mail_api/models/v1_folder_messages_message_text_resource.py +89 -0
  25. hostinger_mail_api/models/v1_folder_messages_move_bulk_request.py +88 -0
  26. hostinger_mail_api/models/v1_folder_messages_move_request.py +86 -0
  27. hostinger_mail_api/models/v1_folder_messages_resource.py +89 -0
  28. hostinger_mail_api/models/v1_folder_messages_search_request.py +111 -0
  29. hostinger_mail_api/models/v1_folder_messages_update_flags_result.py +89 -0
  30. hostinger_mail_api/models/v1_folder_messages_update_flags_result_data.py +95 -0
  31. hostinger_mail_api/models/v1_folder_messages_update_flags_result_data_failed_inner.py +87 -0
  32. hostinger_mail_api/models/v1_folders_collection.py +99 -0
  33. hostinger_mail_api/models/v1_folders_create_request.py +86 -0
  34. hostinger_mail_api/models/v1_folders_folder.py +100 -0
  35. hostinger_mail_api/models/v1_folders_resource.py +89 -0
  36. hostinger_mail_api/models/v1_folders_update_request.py +86 -0
  37. hostinger_mail_api/models/v1_me_mailbox.py +95 -0
  38. hostinger_mail_api/models/v1_me_resource.py +89 -0
  39. hostinger_mail_api/models/v1_me_resource_data.py +103 -0
  40. hostinger_mail_api/models/v1_quota_quota.py +101 -0
  41. hostinger_mail_api/models/v1_quota_quota_resource.py +91 -0
  42. hostinger_mail_api/models/v1_quota_resource.py +89 -0
  43. hostinger_mail_api/models/v1_send_attachment.py +93 -0
  44. hostinger_mail_api/models/v1_send_request.py +92 -0
  45. hostinger_mail_api/models/v1_webhooks_collection.py +99 -0
  46. hostinger_mail_api/models/v1_webhooks_create_request.py +117 -0
  47. hostinger_mail_api/models/v1_webhooks_resource.py +89 -0
  48. hostinger_mail_api/models/v1_webhooks_resource_with_secret.py +89 -0
  49. hostinger_mail_api/models/v1_webhooks_test_result.py +89 -0
  50. hostinger_mail_api/models/v1_webhooks_test_result_data.py +94 -0
  51. hostinger_mail_api/models/v1_webhooks_update_request.py +120 -0
  52. hostinger_mail_api/models/v1_webhooks_webhook.py +132 -0
  53. hostinger_mail_api/models/v1_webhooks_webhook_with_secret.py +134 -0
  54. hostinger_mail_api/py.typed +0 -0
  55. hostinger_mail_api/rest.py +256 -0
  56. hostinger_mail_api-1.0.3.dist-info/METADATA +180 -0
  57. hostinger_mail_api-1.0.3.dist-info/RECORD +59 -0
  58. hostinger_mail_api-1.0.3.dist-info/WHEEL +5 -0
  59. hostinger_mail_api-1.0.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,214 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger Email API Python SDK
5
+
6
+ API Version: 1.0.0
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+ from typing import Any, Optional
13
+ from typing_extensions import Self
14
+
15
+ class OpenApiException(Exception):
16
+ """The base exception class for all OpenAPIExceptions"""
17
+
18
+
19
+ class ApiTypeError(OpenApiException, TypeError):
20
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
21
+ key_type=None) -> None:
22
+ """ Raises an exception for TypeErrors
23
+
24
+ Args:
25
+ msg (str): the exception message
26
+
27
+ Keyword Args:
28
+ path_to_item (list): a list of keys an indices to get to the
29
+ current_item
30
+ None if unset
31
+ valid_classes (tuple): the primitive classes that current item
32
+ should be an instance of
33
+ None if unset
34
+ key_type (bool): False if our value is a value in a dict
35
+ True if it is a key in a dict
36
+ False if our item is an item in a list
37
+ None if unset
38
+ """
39
+ self.path_to_item = path_to_item
40
+ self.valid_classes = valid_classes
41
+ self.key_type = key_type
42
+ full_msg = msg
43
+ if path_to_item:
44
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45
+ super(ApiTypeError, self).__init__(full_msg)
46
+
47
+
48
+ class ApiValueError(OpenApiException, ValueError):
49
+ def __init__(self, msg, path_to_item=None) -> None:
50
+ """
51
+ Args:
52
+ msg (str): the exception message
53
+
54
+ Keyword Args:
55
+ path_to_item (list) the path to the exception in the
56
+ received_data dict. None if unset
57
+ """
58
+
59
+ self.path_to_item = path_to_item
60
+ full_msg = msg
61
+ if path_to_item:
62
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63
+ super(ApiValueError, self).__init__(full_msg)
64
+
65
+
66
+ class ApiAttributeError(OpenApiException, AttributeError):
67
+ def __init__(self, msg, path_to_item=None) -> None:
68
+ """
69
+ Raised when an attribute reference or assignment fails.
70
+
71
+ Args:
72
+ msg (str): the exception message
73
+
74
+ Keyword Args:
75
+ path_to_item (None/list) the path to the exception in the
76
+ received_data dict
77
+ """
78
+ self.path_to_item = path_to_item
79
+ full_msg = msg
80
+ if path_to_item:
81
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82
+ super(ApiAttributeError, self).__init__(full_msg)
83
+
84
+
85
+ class ApiKeyError(OpenApiException, KeyError):
86
+ def __init__(self, msg, path_to_item=None) -> None:
87
+ """
88
+ Args:
89
+ msg (str): the exception message
90
+
91
+ Keyword Args:
92
+ path_to_item (None/list) the path to the exception in the
93
+ received_data dict
94
+ """
95
+ self.path_to_item = path_to_item
96
+ full_msg = msg
97
+ if path_to_item:
98
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99
+ super(ApiKeyError, self).__init__(full_msg)
100
+
101
+
102
+ class ApiException(OpenApiException):
103
+
104
+ def __init__(
105
+ self,
106
+ status=None,
107
+ reason=None,
108
+ http_resp=None,
109
+ *,
110
+ body: Optional[str] = None,
111
+ data: Optional[Any] = None,
112
+ ) -> None:
113
+ self.status = status
114
+ self.reason = reason
115
+ self.body = body
116
+ self.data = data
117
+ self.headers = None
118
+
119
+ if http_resp:
120
+ if self.status is None:
121
+ self.status = http_resp.status
122
+ if self.reason is None:
123
+ self.reason = http_resp.reason
124
+ if self.body is None:
125
+ try:
126
+ self.body = http_resp.data.decode('utf-8')
127
+ except Exception:
128
+ pass
129
+ self.headers = http_resp.getheaders()
130
+
131
+ @classmethod
132
+ def from_response(
133
+ cls,
134
+ *,
135
+ http_resp,
136
+ body: Optional[str],
137
+ data: Optional[Any],
138
+ ) -> Self:
139
+ if http_resp.status == 400:
140
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
141
+
142
+ if http_resp.status == 401:
143
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 403:
146
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 404:
149
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
150
+
151
+ # Added new conditions for 409 and 422
152
+ if http_resp.status == 409:
153
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
154
+
155
+ if http_resp.status == 422:
156
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
157
+
158
+ if 500 <= http_resp.status <= 599:
159
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
160
+ raise ApiException(http_resp=http_resp, body=body, data=data)
161
+
162
+ def __str__(self):
163
+ """Custom error messages for exception"""
164
+ error_message = "({0})\n"\
165
+ "Reason: {1}\n".format(self.status, self.reason)
166
+ if self.headers:
167
+ error_message += "HTTP response headers: {0}\n".format(
168
+ self.headers)
169
+
170
+ if self.data or self.body:
171
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
172
+
173
+ return error_message
174
+
175
+
176
+ class BadRequestException(ApiException):
177
+ pass
178
+
179
+
180
+ class NotFoundException(ApiException):
181
+ pass
182
+
183
+
184
+ class UnauthorizedException(ApiException):
185
+ pass
186
+
187
+
188
+ class ForbiddenException(ApiException):
189
+ pass
190
+
191
+
192
+ class ServiceException(ApiException):
193
+ pass
194
+
195
+
196
+ class ConflictException(ApiException):
197
+ """Exception for HTTP 409 Conflict."""
198
+ pass
199
+
200
+
201
+ class UnprocessableEntityException(ApiException):
202
+ """Exception for HTTP 422 Unprocessable Entity."""
203
+ pass
204
+
205
+
206
+ def render_path(path_to_item):
207
+ """Returns a string representation of a path"""
208
+ result = ""
209
+ for pth in path_to_item:
210
+ if isinstance(pth, int):
211
+ result += "[{0}]".format(pth)
212
+ else:
213
+ result += "['{0}']".format(pth)
214
+ return result
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ Hostinger Email API Python SDK
6
+
7
+ API Version: 1.0.0
8
+
9
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11
+ """ # noqa: E501
12
+
13
+
14
+ # import models into model package
15
+ from hostinger_mail_api.models.error import Error
16
+ from hostinger_mail_api.models.pagination import Pagination
17
+ from hostinger_mail_api.models.v1_folder_messages_collection import V1FolderMessagesCollection
18
+ from hostinger_mail_api.models.v1_folder_messages_delete_bulk_request import V1FolderMessagesDeleteBulkRequest
19
+ from hostinger_mail_api.models.v1_folder_messages_flags_bulk_request import V1FolderMessagesFlagsBulkRequest
20
+ from hostinger_mail_api.models.v1_folder_messages_flags_request import V1FolderMessagesFlagsRequest
21
+ from hostinger_mail_api.models.v1_folder_messages_message import V1FolderMessagesMessage
22
+ from hostinger_mail_api.models.v1_folder_messages_message_address import V1FolderMessagesMessageAddress
23
+ from hostinger_mail_api.models.v1_folder_messages_message_attachment import V1FolderMessagesMessageAttachment
24
+ from hostinger_mail_api.models.v1_folder_messages_message_text import V1FolderMessagesMessageText
25
+ from hostinger_mail_api.models.v1_folder_messages_message_text_resource import V1FolderMessagesMessageTextResource
26
+ from hostinger_mail_api.models.v1_folder_messages_move_bulk_request import V1FolderMessagesMoveBulkRequest
27
+ from hostinger_mail_api.models.v1_folder_messages_move_request import V1FolderMessagesMoveRequest
28
+ from hostinger_mail_api.models.v1_folder_messages_resource import V1FolderMessagesResource
29
+ from hostinger_mail_api.models.v1_folder_messages_search_request import V1FolderMessagesSearchRequest
30
+ from hostinger_mail_api.models.v1_folder_messages_update_flags_result import V1FolderMessagesUpdateFlagsResult
31
+ from hostinger_mail_api.models.v1_folder_messages_update_flags_result_data import V1FolderMessagesUpdateFlagsResultData
32
+ from hostinger_mail_api.models.v1_folder_messages_update_flags_result_data_failed_inner import V1FolderMessagesUpdateFlagsResultDataFailedInner
33
+ from hostinger_mail_api.models.v1_folders_collection import V1FoldersCollection
34
+ from hostinger_mail_api.models.v1_folders_create_request import V1FoldersCreateRequest
35
+ from hostinger_mail_api.models.v1_folders_folder import V1FoldersFolder
36
+ from hostinger_mail_api.models.v1_folders_resource import V1FoldersResource
37
+ from hostinger_mail_api.models.v1_folders_update_request import V1FoldersUpdateRequest
38
+ from hostinger_mail_api.models.v1_me_mailbox import V1MeMailbox
39
+ from hostinger_mail_api.models.v1_me_resource import V1MeResource
40
+ from hostinger_mail_api.models.v1_me_resource_data import V1MeResourceData
41
+ from hostinger_mail_api.models.v1_quota_quota import V1QuotaQuota
42
+ from hostinger_mail_api.models.v1_quota_quota_resource import V1QuotaQuotaResource
43
+ from hostinger_mail_api.models.v1_quota_resource import V1QuotaResource
44
+ from hostinger_mail_api.models.v1_send_attachment import V1SendAttachment
45
+ from hostinger_mail_api.models.v1_send_request import V1SendRequest
46
+ from hostinger_mail_api.models.v1_webhooks_collection import V1WebhooksCollection
47
+ from hostinger_mail_api.models.v1_webhooks_create_request import V1WebhooksCreateRequest
48
+ from hostinger_mail_api.models.v1_webhooks_resource import V1WebhooksResource
49
+ from hostinger_mail_api.models.v1_webhooks_resource_with_secret import V1WebhooksResourceWithSecret
50
+ from hostinger_mail_api.models.v1_webhooks_test_result import V1WebhooksTestResult
51
+ from hostinger_mail_api.models.v1_webhooks_test_result_data import V1WebhooksTestResultData
52
+ from hostinger_mail_api.models.v1_webhooks_update_request import V1WebhooksUpdateRequest
53
+ from hostinger_mail_api.models.v1_webhooks_webhook import V1WebhooksWebhook
54
+ from hostinger_mail_api.models.v1_webhooks_webhook_with_secret import V1WebhooksWebhookWithSecret
@@ -0,0 +1,89 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger Email API Python SDK
5
+
6
+ API Version: 1.0.0
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
19
+ from typing import Any, ClassVar, Dict, List, Optional
20
+ from typing import Optional, Set
21
+ from typing_extensions import Self
22
+
23
+ class Error(BaseModel):
24
+ """
25
+ Standard error envelope. Frontend translations key off `code`, never off `error`.
26
+ """ # noqa: E501
27
+ error: StrictStr = Field(description="Human-readable error message.")
28
+ code: StrictStr = Field(description="Machine-readable error code in SCREAMING_SNAKE_CASE.")
29
+ params: Optional[Dict[str, Any]] = Field(default=None, description="Additional structured context for the error. May be omitted.")
30
+ __properties: ClassVar[List[str]] = ["error", "code", "params"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of Error from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([
64
+ ])
65
+
66
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ return _dict
72
+
73
+ @classmethod
74
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
75
+ """Create an instance of Error from a dict"""
76
+ if obj is None:
77
+ return None
78
+
79
+ if not isinstance(obj, dict):
80
+ return cls.model_validate(obj)
81
+
82
+ _obj = cls.model_validate({
83
+ "error": obj.get("error"),
84
+ "code": obj.get("code"),
85
+ "params": obj.get("params")
86
+ })
87
+ return _obj
88
+
89
+
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger Email API Python SDK
5
+
6
+ API Version: 1.0.0
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt
19
+ from typing import Any, ClassVar, Dict, List
20
+ from typing import Optional, Set
21
+ from typing_extensions import Self
22
+
23
+ class Pagination(BaseModel):
24
+ """
25
+ Pagination metadata for paginated collections.
26
+ """ # noqa: E501
27
+ page: StrictInt = Field(description="Current page number (1-based).")
28
+ per_page: StrictInt = Field(description="Items per page.", alias="perPage")
29
+ total: StrictInt = Field(description="Total number of items across all pages.")
30
+ total_pages: StrictInt = Field(description="Total number of pages.", alias="totalPages")
31
+ __properties: ClassVar[List[str]] = ["page", "perPage", "total", "totalPages"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of Pagination from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of Pagination from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj)
82
+
83
+ _obj = cls.model_validate({
84
+ "page": obj.get("page"),
85
+ "perPage": obj.get("perPage"),
86
+ "total": obj.get("total"),
87
+ "totalPages": obj.get("totalPages")
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger Email API Python SDK
5
+
6
+ API Version: 1.0.0
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict
19
+ from typing import Any, ClassVar, Dict, List
20
+ from hostinger_mail_api.models.pagination import Pagination
21
+ from hostinger_mail_api.models.v1_folder_messages_message import V1FolderMessagesMessage
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class V1FolderMessagesCollection(BaseModel):
26
+ """
27
+ Paginated list of messages.
28
+ """ # noqa: E501
29
+ data: List[V1FolderMessagesMessage]
30
+ pagination: Pagination
31
+ __properties: ClassVar[List[str]] = ["data", "pagination"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of V1FolderMessagesCollection from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # override the default output from pydantic by calling `to_dict()` of each item in data (list)
73
+ _items = []
74
+ if self.data:
75
+ for _item_data in self.data:
76
+ if _item_data:
77
+ _items.append(_item_data.to_dict())
78
+ _dict['data'] = _items
79
+ # override the default output from pydantic by calling `to_dict()` of pagination
80
+ if self.pagination:
81
+ _dict['pagination'] = self.pagination.to_dict()
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of V1FolderMessagesCollection from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "data": [V1FolderMessagesMessage.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None,
95
+ "pagination": Pagination.from_dict(obj["pagination"]) if obj.get("pagination") is not None else None
96
+ })
97
+ return _obj
98
+
99
+
@@ -0,0 +1,86 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger Email API Python SDK
5
+
6
+ API Version: 1.0.0
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field
19
+ from typing import Any, ClassVar, Dict, List
20
+ from typing_extensions import Annotated
21
+ from typing import Optional, Set
22
+ from typing_extensions import Self
23
+
24
+ class V1FolderMessagesDeleteBulkRequest(BaseModel):
25
+ """
26
+ Body for permanently deleting multiple messages.
27
+ """ # noqa: E501
28
+ uids: Annotated[List[Annotated[int, Field(strict=True, ge=1)]], Field(min_length=1, max_length=100)] = Field(description="Message UIDs to delete. 1-100 entries, each > 0.")
29
+ __properties: ClassVar[List[str]] = ["uids"]
30
+
31
+ model_config = ConfigDict(
32
+ populate_by_name=True,
33
+ validate_assignment=True,
34
+ protected_namespaces=(),
35
+ )
36
+
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of V1FolderMessagesDeleteBulkRequest from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([
63
+ ])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ return _dict
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74
+ """Create an instance of V1FolderMessagesDeleteBulkRequest from a dict"""
75
+ if obj is None:
76
+ return None
77
+
78
+ if not isinstance(obj, dict):
79
+ return cls.model_validate(obj)
80
+
81
+ _obj = cls.model_validate({
82
+ "uids": obj.get("uids")
83
+ })
84
+ return _obj
85
+
86
+