mailmus 0.2.0__tar.gz
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.
- mailmus-0.2.0/PKG-INFO +192 -0
- mailmus-0.2.0/README.md +176 -0
- mailmus-0.2.0/pyproject.toml +30 -0
- mailmus-0.2.0/setup.cfg +4 -0
- mailmus-0.2.0/src/mailmus/__init__.py +129 -0
- mailmus-0.2.0/src/mailmus/_default_clients.py +30 -0
- mailmus-0.2.0/src/mailmus/account/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/account/client.py +414 -0
- mailmus-0.2.0/src/mailmus/account/raw_client.py +423 -0
- mailmus-0.2.0/src/mailmus/account_analytics/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/account_analytics/client.py +97 -0
- mailmus-0.2.0/src/mailmus/account_analytics/raw_client.py +81 -0
- mailmus-0.2.0/src/mailmus/analytics/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/analytics/client.py +243 -0
- mailmus-0.2.0/src/mailmus/analytics/raw_client.py +214 -0
- mailmus-0.2.0/src/mailmus/api_keys/__init__.py +34 -0
- mailmus-0.2.0/src/mailmus/api_keys/client.py +277 -0
- mailmus-0.2.0/src/mailmus/api_keys/raw_client.py +256 -0
- mailmus-0.2.0/src/mailmus/api_keys/types/__init__.py +34 -0
- mailmus-0.2.0/src/mailmus/api_keys/types/create_api_key_dto_type.py +5 -0
- mailmus-0.2.0/src/mailmus/app/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/app/client.py +95 -0
- mailmus-0.2.0/src/mailmus/app/raw_client.py +79 -0
- mailmus-0.2.0/src/mailmus/apps/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/apps/client.py +370 -0
- mailmus-0.2.0/src/mailmus/apps/raw_client.py +371 -0
- mailmus-0.2.0/src/mailmus/audiences/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/audiences/client.py +822 -0
- mailmus-0.2.0/src/mailmus/audiences/raw_client.py +783 -0
- mailmus-0.2.0/src/mailmus/auth/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/auth/client.py +428 -0
- mailmus-0.2.0/src/mailmus/auth/raw_client.py +478 -0
- mailmus-0.2.0/src/mailmus/automations/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/automations/client.py +510 -0
- mailmus-0.2.0/src/mailmus/automations/raw_client.py +477 -0
- mailmus-0.2.0/src/mailmus/billing/__init__.py +34 -0
- mailmus-0.2.0/src/mailmus/billing/client.py +229 -0
- mailmus-0.2.0/src/mailmus/billing/raw_client.py +223 -0
- mailmus-0.2.0/src/mailmus/billing/types/__init__.py +34 -0
- mailmus-0.2.0/src/mailmus/billing/types/create_checkout_dto_plan.py +5 -0
- mailmus-0.2.0/src/mailmus/billing_webhook/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/billing_webhook/client.py +111 -0
- mailmus-0.2.0/src/mailmus/billing_webhook/raw_client.py +91 -0
- mailmus-0.2.0/src/mailmus/campaigns/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/campaigns/client.py +1048 -0
- mailmus-0.2.0/src/mailmus/campaigns/raw_client.py +975 -0
- mailmus-0.2.0/src/mailmus/client.py +588 -0
- mailmus-0.2.0/src/mailmus/contacts/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/contacts/client.py +838 -0
- mailmus-0.2.0/src/mailmus/contacts/raw_client.py +799 -0
- mailmus-0.2.0/src/mailmus/core/__init__.py +127 -0
- mailmus-0.2.0/src/mailmus/core/api_error.py +23 -0
- mailmus-0.2.0/src/mailmus/core/client_wrapper.py +118 -0
- mailmus-0.2.0/src/mailmus/core/datetime_utils.py +70 -0
- mailmus-0.2.0/src/mailmus/core/file.py +67 -0
- mailmus-0.2.0/src/mailmus/core/force_multipart.py +18 -0
- mailmus-0.2.0/src/mailmus/core/http_client.py +839 -0
- mailmus-0.2.0/src/mailmus/core/http_response.py +59 -0
- mailmus-0.2.0/src/mailmus/core/http_sse/__init__.py +42 -0
- mailmus-0.2.0/src/mailmus/core/http_sse/_api.py +170 -0
- mailmus-0.2.0/src/mailmus/core/http_sse/_decoders.py +61 -0
- mailmus-0.2.0/src/mailmus/core/http_sse/_exceptions.py +7 -0
- mailmus-0.2.0/src/mailmus/core/http_sse/_models.py +17 -0
- mailmus-0.2.0/src/mailmus/core/jsonable_encoder.py +120 -0
- mailmus-0.2.0/src/mailmus/core/logging.py +107 -0
- mailmus-0.2.0/src/mailmus/core/parse_error.py +36 -0
- mailmus-0.2.0/src/mailmus/core/pydantic_utilities.py +508 -0
- mailmus-0.2.0/src/mailmus/core/query_encoder.py +58 -0
- mailmus-0.2.0/src/mailmus/core/remove_none_from_dict.py +11 -0
- mailmus-0.2.0/src/mailmus/core/request_options.py +35 -0
- mailmus-0.2.0/src/mailmus/core/serialization.py +347 -0
- mailmus-0.2.0/src/mailmus/domains/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/domains/client.py +332 -0
- mailmus-0.2.0/src/mailmus/domains/raw_client.py +307 -0
- mailmus-0.2.0/src/mailmus/emails/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/emails/client.py +500 -0
- mailmus-0.2.0/src/mailmus/emails/raw_client.py +466 -0
- mailmus-0.2.0/src/mailmus/public/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/public/client.py +150 -0
- mailmus-0.2.0/src/mailmus/public/raw_client.py +132 -0
- mailmus-0.2.0/src/mailmus/py.typed +0 -0
- mailmus-0.2.0/src/mailmus/ses_webhook/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/ses_webhook/client.py +111 -0
- mailmus-0.2.0/src/mailmus/ses_webhook/raw_client.py +91 -0
- mailmus-0.2.0/src/mailmus/suppressions/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/suppressions/client.py +256 -0
- mailmus-0.2.0/src/mailmus/suppressions/raw_client.py +243 -0
- mailmus-0.2.0/src/mailmus/templates/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/templates/client.py +544 -0
- mailmus-0.2.0/src/mailmus/templates/raw_client.py +511 -0
- mailmus-0.2.0/src/mailmus/tracking/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/tracking/client.py +341 -0
- mailmus-0.2.0/src/mailmus/tracking/raw_client.py +314 -0
- mailmus-0.2.0/src/mailmus/types/__init__.py +38 -0
- mailmus-0.2.0/src/mailmus/types/email_attachment_dto.py +29 -0
- mailmus-0.2.0/src/mailmus/types/send_transactional_email_dto.py +57 -0
- mailmus-0.2.0/src/mailmus/usage/__init__.py +4 -0
- mailmus-0.2.0/src/mailmus/usage/client.py +95 -0
- mailmus-0.2.0/src/mailmus/usage/raw_client.py +79 -0
- mailmus-0.2.0/src/mailmus/webhooks/__init__.py +37 -0
- mailmus-0.2.0/src/mailmus/webhooks/client.py +628 -0
- mailmus-0.2.0/src/mailmus/webhooks/raw_client.py +577 -0
- mailmus-0.2.0/src/mailmus/webhooks/types/__init__.py +38 -0
- mailmus-0.2.0/src/mailmus/webhooks/types/create_webhook_dto_events_item.py +22 -0
- mailmus-0.2.0/src/mailmus/webhooks/types/update_webhook_dto_events_item.py +22 -0
- mailmus-0.2.0/src/mailmus.egg-info/PKG-INFO +192 -0
- mailmus-0.2.0/src/mailmus.egg-info/SOURCES.txt +109 -0
- mailmus-0.2.0/src/mailmus.egg-info/dependency_links.txt +1 -0
- mailmus-0.2.0/src/mailmus.egg-info/requires.txt +6 -0
- mailmus-0.2.0/src/mailmus.egg-info/top_level.txt +1 -0
- mailmus-0.2.0/tests/test_aiohttp_autodetect.py +113 -0
mailmus-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mailmus
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Official Python SDK for the Mailmus API
|
|
5
|
+
Author-email: Mailmus <support@mailmus.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://mailmus.com
|
|
8
|
+
Project-URL: Repository, https://github.com/mailmus/mailmus-python
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: httpx>=0.21.2
|
|
12
|
+
Requires-Dist: pydantic>=1.9.2
|
|
13
|
+
Requires-Dist: typing_extensions>=4.0.0
|
|
14
|
+
Provides-Extra: aiohttp
|
|
15
|
+
Requires-Dist: httpx-aiohttp>=0.1.8; extra == "aiohttp"
|
|
16
|
+
|
|
17
|
+
# Mailmus Python Library
|
|
18
|
+
|
|
19
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Mailmus%2FPython)
|
|
20
|
+
[](https://pypi.python.org/pypi/mailmus)
|
|
21
|
+
|
|
22
|
+
The Mailmus Python library provides convenient access to the Mailmus APIs from Python.
|
|
23
|
+
|
|
24
|
+
## Table of Contents
|
|
25
|
+
|
|
26
|
+
- [Installation](#installation)
|
|
27
|
+
- [Reference](#reference)
|
|
28
|
+
- [Usage](#usage)
|
|
29
|
+
- [Async Client](#async-client)
|
|
30
|
+
- [Exception Handling](#exception-handling)
|
|
31
|
+
- [Advanced](#advanced)
|
|
32
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
33
|
+
- [Retries](#retries)
|
|
34
|
+
- [Timeouts](#timeouts)
|
|
35
|
+
- [Custom Client](#custom-client)
|
|
36
|
+
- [Contributing](#contributing)
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pip install mailmus
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Reference
|
|
45
|
+
|
|
46
|
+
A full reference for this library is available [here](./reference.md).
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
Instantiate and use the client with the following:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from mailmus import MailmusApi
|
|
54
|
+
|
|
55
|
+
client = MailmusApi(
|
|
56
|
+
token="<token>",
|
|
57
|
+
base_url="https://yourhost.com/path/to/api",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
client.suppressions.suppressions_controller_create(
|
|
61
|
+
email="bounced@example.com",
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Async Client
|
|
66
|
+
|
|
67
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import asyncio
|
|
71
|
+
|
|
72
|
+
from mailmus import AsyncMailmusApi
|
|
73
|
+
|
|
74
|
+
client = AsyncMailmusApi(
|
|
75
|
+
token="<token>",
|
|
76
|
+
base_url="https://yourhost.com/path/to/api",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def main() -> None:
|
|
81
|
+
await client.suppressions.suppressions_controller_create(
|
|
82
|
+
email="bounced@example.com",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
asyncio.run(main())
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Exception Handling
|
|
90
|
+
|
|
91
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
92
|
+
will be thrown.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from mailmus.core.api_error import ApiError
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
client.suppressions.suppressions_controller_create(...)
|
|
99
|
+
except ApiError as e:
|
|
100
|
+
print(e.status_code)
|
|
101
|
+
print(e.body)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Advanced
|
|
105
|
+
|
|
106
|
+
### Access Raw Response Data
|
|
107
|
+
|
|
108
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
109
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from mailmus import MailmusApi
|
|
113
|
+
|
|
114
|
+
client = MailmusApi(...)
|
|
115
|
+
response = client.suppressions.with_raw_response.suppressions_controller_create(...)
|
|
116
|
+
print(response.headers) # access the response headers
|
|
117
|
+
print(response.status_code) # access the response status code
|
|
118
|
+
print(response.data) # access the underlying object
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Retries
|
|
122
|
+
|
|
123
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
124
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
125
|
+
retry limit (default: 2).
|
|
126
|
+
|
|
127
|
+
Which status codes are retried depends on the `retryStatusCodes` generator configuration:
|
|
128
|
+
|
|
129
|
+
**`legacy`** (current default): retries on
|
|
130
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
131
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
132
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
133
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
|
|
134
|
+
|
|
135
|
+
**`recommended`**: retries on
|
|
136
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
137
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
138
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
139
|
+
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
|
|
140
|
+
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
|
|
141
|
+
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
|
|
142
|
+
|
|
143
|
+
Use the `max_retries` request option to configure this behavior.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
client.suppressions.suppressions_controller_create(..., request_options={
|
|
147
|
+
"max_retries": 1
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Timeouts
|
|
152
|
+
|
|
153
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from mailmus import MailmusApi
|
|
157
|
+
|
|
158
|
+
client = MailmusApi(..., timeout=20.0)
|
|
159
|
+
|
|
160
|
+
# Override timeout for a specific method
|
|
161
|
+
client.suppressions.suppressions_controller_create(..., request_options={
|
|
162
|
+
"timeout_in_seconds": 1
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Custom Client
|
|
167
|
+
|
|
168
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
169
|
+
and transports.
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
import httpx
|
|
173
|
+
from mailmus import MailmusApi
|
|
174
|
+
|
|
175
|
+
client = MailmusApi(
|
|
176
|
+
...,
|
|
177
|
+
httpx_client=httpx.Client(
|
|
178
|
+
proxy="http://my.test.proxy.example.com",
|
|
179
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
186
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
187
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
188
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
189
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
190
|
+
an issue first to discuss with us!
|
|
191
|
+
|
|
192
|
+
On the other hand, contributions to the README are always very welcome!
|
mailmus-0.2.0/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Mailmus Python Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Mailmus%2FPython)
|
|
4
|
+
[](https://pypi.python.org/pypi/mailmus)
|
|
5
|
+
|
|
6
|
+
The Mailmus Python library provides convenient access to the Mailmus APIs from Python.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Reference](#reference)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Async Client](#async-client)
|
|
14
|
+
- [Exception Handling](#exception-handling)
|
|
15
|
+
- [Advanced](#advanced)
|
|
16
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
17
|
+
- [Retries](#retries)
|
|
18
|
+
- [Timeouts](#timeouts)
|
|
19
|
+
- [Custom Client](#custom-client)
|
|
20
|
+
- [Contributing](#contributing)
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pip install mailmus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Reference
|
|
29
|
+
|
|
30
|
+
A full reference for this library is available [here](./reference.md).
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Instantiate and use the client with the following:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from mailmus import MailmusApi
|
|
38
|
+
|
|
39
|
+
client = MailmusApi(
|
|
40
|
+
token="<token>",
|
|
41
|
+
base_url="https://yourhost.com/path/to/api",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
client.suppressions.suppressions_controller_create(
|
|
45
|
+
email="bounced@example.com",
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Async Client
|
|
50
|
+
|
|
51
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import asyncio
|
|
55
|
+
|
|
56
|
+
from mailmus import AsyncMailmusApi
|
|
57
|
+
|
|
58
|
+
client = AsyncMailmusApi(
|
|
59
|
+
token="<token>",
|
|
60
|
+
base_url="https://yourhost.com/path/to/api",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def main() -> None:
|
|
65
|
+
await client.suppressions.suppressions_controller_create(
|
|
66
|
+
email="bounced@example.com",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
asyncio.run(main())
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Exception Handling
|
|
74
|
+
|
|
75
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
76
|
+
will be thrown.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from mailmus.core.api_error import ApiError
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
client.suppressions.suppressions_controller_create(...)
|
|
83
|
+
except ApiError as e:
|
|
84
|
+
print(e.status_code)
|
|
85
|
+
print(e.body)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Advanced
|
|
89
|
+
|
|
90
|
+
### Access Raw Response Data
|
|
91
|
+
|
|
92
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
93
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from mailmus import MailmusApi
|
|
97
|
+
|
|
98
|
+
client = MailmusApi(...)
|
|
99
|
+
response = client.suppressions.with_raw_response.suppressions_controller_create(...)
|
|
100
|
+
print(response.headers) # access the response headers
|
|
101
|
+
print(response.status_code) # access the response status code
|
|
102
|
+
print(response.data) # access the underlying object
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Retries
|
|
106
|
+
|
|
107
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
108
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
109
|
+
retry limit (default: 2).
|
|
110
|
+
|
|
111
|
+
Which status codes are retried depends on the `retryStatusCodes` generator configuration:
|
|
112
|
+
|
|
113
|
+
**`legacy`** (current default): retries on
|
|
114
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
115
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
116
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
117
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
|
|
118
|
+
|
|
119
|
+
**`recommended`**: retries on
|
|
120
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
121
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
122
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
123
|
+
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
|
|
124
|
+
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
|
|
125
|
+
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
|
|
126
|
+
|
|
127
|
+
Use the `max_retries` request option to configure this behavior.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
client.suppressions.suppressions_controller_create(..., request_options={
|
|
131
|
+
"max_retries": 1
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Timeouts
|
|
136
|
+
|
|
137
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from mailmus import MailmusApi
|
|
141
|
+
|
|
142
|
+
client = MailmusApi(..., timeout=20.0)
|
|
143
|
+
|
|
144
|
+
# Override timeout for a specific method
|
|
145
|
+
client.suppressions.suppressions_controller_create(..., request_options={
|
|
146
|
+
"timeout_in_seconds": 1
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Custom Client
|
|
151
|
+
|
|
152
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
153
|
+
and transports.
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
import httpx
|
|
157
|
+
from mailmus import MailmusApi
|
|
158
|
+
|
|
159
|
+
client = MailmusApi(
|
|
160
|
+
...,
|
|
161
|
+
httpx_client=httpx.Client(
|
|
162
|
+
proxy="http://my.test.proxy.example.com",
|
|
163
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
171
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
172
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
173
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
174
|
+
an issue first to discuss with us!
|
|
175
|
+
|
|
176
|
+
On the other hand, contributions to the README are always very welcome!
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mailmus"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Official Python SDK for the Mailmus API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Mailmus", email = "support@mailmus.com" }]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"httpx>=0.21.2",
|
|
15
|
+
"pydantic>=1.9.2",
|
|
16
|
+
"typing_extensions>=4.0.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
aiohttp = ["httpx-aiohttp>=0.1.8"]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://mailmus.com"
|
|
24
|
+
Repository = "https://github.com/mailmus/mailmus-python"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["src"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.package-data]
|
|
30
|
+
mailmus = ["py.typed"]
|
mailmus-0.2.0/setup.cfg
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .types import EmailAttachmentDto, SendTransactionalEmailDto
|
|
10
|
+
from . import (
|
|
11
|
+
account,
|
|
12
|
+
account_analytics,
|
|
13
|
+
analytics,
|
|
14
|
+
api_keys,
|
|
15
|
+
app,
|
|
16
|
+
apps,
|
|
17
|
+
audiences,
|
|
18
|
+
auth,
|
|
19
|
+
automations,
|
|
20
|
+
billing,
|
|
21
|
+
billing_webhook,
|
|
22
|
+
campaigns,
|
|
23
|
+
contacts,
|
|
24
|
+
domains,
|
|
25
|
+
emails,
|
|
26
|
+
public,
|
|
27
|
+
ses_webhook,
|
|
28
|
+
suppressions,
|
|
29
|
+
templates,
|
|
30
|
+
tracking,
|
|
31
|
+
usage,
|
|
32
|
+
webhooks,
|
|
33
|
+
)
|
|
34
|
+
from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
|
|
35
|
+
from .api_keys import CreateApiKeyDtoType
|
|
36
|
+
from .billing import CreateCheckoutDtoPlan
|
|
37
|
+
from .client import AsyncMailmusApi, MailmusApi
|
|
38
|
+
from .webhooks import CreateWebhookDtoEventsItem, UpdateWebhookDtoEventsItem
|
|
39
|
+
_dynamic_imports: typing.Dict[str, str] = {
|
|
40
|
+
"AsyncMailmusApi": ".client",
|
|
41
|
+
"CreateApiKeyDtoType": ".api_keys",
|
|
42
|
+
"CreateCheckoutDtoPlan": ".billing",
|
|
43
|
+
"CreateWebhookDtoEventsItem": ".webhooks",
|
|
44
|
+
"DefaultAioHttpClient": "._default_clients",
|
|
45
|
+
"DefaultAsyncHttpxClient": "._default_clients",
|
|
46
|
+
"EmailAttachmentDto": ".types",
|
|
47
|
+
"MailmusApi": ".client",
|
|
48
|
+
"SendTransactionalEmailDto": ".types",
|
|
49
|
+
"UpdateWebhookDtoEventsItem": ".webhooks",
|
|
50
|
+
"account": ".account",
|
|
51
|
+
"account_analytics": ".account_analytics",
|
|
52
|
+
"analytics": ".analytics",
|
|
53
|
+
"api_keys": ".api_keys",
|
|
54
|
+
"app": ".app",
|
|
55
|
+
"apps": ".apps",
|
|
56
|
+
"audiences": ".audiences",
|
|
57
|
+
"auth": ".auth",
|
|
58
|
+
"automations": ".automations",
|
|
59
|
+
"billing": ".billing",
|
|
60
|
+
"billing_webhook": ".billing_webhook",
|
|
61
|
+
"campaigns": ".campaigns",
|
|
62
|
+
"contacts": ".contacts",
|
|
63
|
+
"domains": ".domains",
|
|
64
|
+
"emails": ".emails",
|
|
65
|
+
"public": ".public",
|
|
66
|
+
"ses_webhook": ".ses_webhook",
|
|
67
|
+
"suppressions": ".suppressions",
|
|
68
|
+
"templates": ".templates",
|
|
69
|
+
"tracking": ".tracking",
|
|
70
|
+
"usage": ".usage",
|
|
71
|
+
"webhooks": ".webhooks",
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
76
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
77
|
+
if module_name is None:
|
|
78
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
79
|
+
try:
|
|
80
|
+
module = import_module(module_name, __package__)
|
|
81
|
+
if module_name == f".{attr_name}":
|
|
82
|
+
return module
|
|
83
|
+
else:
|
|
84
|
+
return getattr(module, attr_name)
|
|
85
|
+
except ImportError as e:
|
|
86
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
87
|
+
except AttributeError as e:
|
|
88
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def __dir__():
|
|
92
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
93
|
+
return sorted(lazy_attrs)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
__all__ = [
|
|
97
|
+
"AsyncMailmusApi",
|
|
98
|
+
"CreateApiKeyDtoType",
|
|
99
|
+
"CreateCheckoutDtoPlan",
|
|
100
|
+
"CreateWebhookDtoEventsItem",
|
|
101
|
+
"DefaultAioHttpClient",
|
|
102
|
+
"DefaultAsyncHttpxClient",
|
|
103
|
+
"EmailAttachmentDto",
|
|
104
|
+
"MailmusApi",
|
|
105
|
+
"SendTransactionalEmailDto",
|
|
106
|
+
"UpdateWebhookDtoEventsItem",
|
|
107
|
+
"account",
|
|
108
|
+
"account_analytics",
|
|
109
|
+
"analytics",
|
|
110
|
+
"api_keys",
|
|
111
|
+
"app",
|
|
112
|
+
"apps",
|
|
113
|
+
"audiences",
|
|
114
|
+
"auth",
|
|
115
|
+
"automations",
|
|
116
|
+
"billing",
|
|
117
|
+
"billing_webhook",
|
|
118
|
+
"campaigns",
|
|
119
|
+
"contacts",
|
|
120
|
+
"domains",
|
|
121
|
+
"emails",
|
|
122
|
+
"public",
|
|
123
|
+
"ses_webhook",
|
|
124
|
+
"suppressions",
|
|
125
|
+
"templates",
|
|
126
|
+
"tracking",
|
|
127
|
+
"usage",
|
|
128
|
+
"webhooks",
|
|
129
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
SDK_DEFAULT_TIMEOUT = 60
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
11
|
+
except ImportError:
|
|
12
|
+
|
|
13
|
+
class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
|
|
14
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
15
|
+
raise RuntimeError("To use the aiohttp client, install the aiohttp extra: pip install mailmus[aiohttp]")
|
|
16
|
+
|
|
17
|
+
else:
|
|
18
|
+
|
|
19
|
+
class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
|
|
20
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
21
|
+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
|
|
22
|
+
kwargs.setdefault("follow_redirects", True)
|
|
23
|
+
super().__init__(**kwargs)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DefaultAsyncHttpxClient(httpx.AsyncClient):
|
|
27
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
28
|
+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
|
|
29
|
+
kwargs.setdefault("follow_redirects", True)
|
|
30
|
+
super().__init__(**kwargs)
|