teleleo 0.1.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.
- teleleo-0.1.0/.gitignore +12 -0
- teleleo-0.1.0/CHANGELOG.md +7 -0
- teleleo-0.1.0/LICENSE +21 -0
- teleleo-0.1.0/PKG-INFO +215 -0
- teleleo-0.1.0/README.md +182 -0
- teleleo-0.1.0/api.md +185 -0
- teleleo-0.1.0/pyproject.toml +73 -0
- teleleo-0.1.0/src/teleleo/__init__.py +61 -0
- teleleo-0.1.0/src/teleleo/_base_client.py +447 -0
- teleleo-0.1.0/src/teleleo/_client.py +176 -0
- teleleo-0.1.0/src/teleleo/_exceptions.py +201 -0
- teleleo-0.1.0/src/teleleo/_models.py +135 -0
- teleleo-0.1.0/src/teleleo/_pagination.py +133 -0
- teleleo-0.1.0/src/teleleo/_resource.py +22 -0
- teleleo-0.1.0/src/teleleo/_types.py +36 -0
- teleleo-0.1.0/src/teleleo/_utils.py +90 -0
- teleleo-0.1.0/src/teleleo/_version.py +1 -0
- teleleo-0.1.0/src/teleleo/py.typed +0 -0
- teleleo-0.1.0/src/teleleo/resources/__init__.py +205 -0
- teleleo-0.1.0/src/teleleo/resources/call_scenarios.py +553 -0
- teleleo-0.1.0/src/teleleo/resources/calls.py +381 -0
- teleleo-0.1.0/src/teleleo/resources/contact_groups.py +366 -0
- teleleo-0.1.0/src/teleleo/resources/contacts.py +497 -0
- teleleo-0.1.0/src/teleleo/resources/dongles.py +1103 -0
- teleleo-0.1.0/src/teleleo/resources/files.py +287 -0
- teleleo-0.1.0/src/teleleo/resources/follow_up_sms_settings.py +388 -0
- teleleo-0.1.0/src/teleleo/resources/mailings.py +807 -0
- teleleo-0.1.0/src/teleleo/resources/public_vpn.py +245 -0
- teleleo-0.1.0/src/teleleo/resources/redirections.py +408 -0
- teleleo-0.1.0/src/teleleo/resources/sip_users.py +141 -0
- teleleo-0.1.0/src/teleleo/resources/sms.py +807 -0
- teleleo-0.1.0/src/teleleo/resources/socks_proxies.py +338 -0
- teleleo-0.1.0/src/teleleo/resources/ussd.py +344 -0
- teleleo-0.1.0/src/teleleo/types/__init__.py +127 -0
- teleleo-0.1.0/src/teleleo/types/enums.py +282 -0
- teleleo-0.1.0/src/teleleo/types/models.py +1075 -0
- teleleo-0.1.0/src/teleleo/types/params.py +89 -0
teleleo-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [semver](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-11-10
|
|
6
|
+
|
|
7
|
+
First release: sync and async clients for the 82 operations of Teleleo API v1.0.0, typed models and enums, exceptions with API error codes, automatic pagination and retries.
|
teleleo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Teleleo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
teleleo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: teleleo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The official Python library for the Teleleo API: SMS, calls, USSD and modem control
|
|
5
|
+
Project-URL: Homepage, https://teleleo.com
|
|
6
|
+
Project-URL: Documentation, https://github.com/teleleo-com/teleleo-python#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/teleleo-com/teleleo-python
|
|
8
|
+
Project-URL: Changelog, https://github.com/teleleo-com/teleleo-python/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/teleleo-com/teleleo-python/issues
|
|
10
|
+
Author-email: Teleleo <support@teleleo.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: api client,calls,gsm modem,sdk,sim,sms,sms api,socks proxy,teleleo,ussd,vpn
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Communications :: Telephony
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Requires-Dist: httpx<1,>=0.23.0
|
|
30
|
+
Requires-Dist: pydantic<3,>=2.0
|
|
31
|
+
Requires-Dist: typing-extensions>=4.7
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# Teleleo Python library
|
|
35
|
+
|
|
36
|
+
Teleleo is a platform for managing SIM-card modems from the cloud: SMS, calls, USSD, mailings, redirections, Wi-Fi, VPN and SOCKS proxy. `teleleo` is the official Python library for the [Teleleo REST API](https://github.com/teleleo-com/teleleo-openapi).
|
|
37
|
+
|
|
38
|
+
- Sync and async clients
|
|
39
|
+
- Typed models and enums for every answer, docstrings on every method
|
|
40
|
+
- Every error is an exception with the API error code
|
|
41
|
+
- Automatic pagination and retries
|
|
42
|
+
- Python 3.9+
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install teleleo
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quickstart
|
|
51
|
+
|
|
52
|
+
Take the API key in the Teleleo cabinet (Settings → API key) and put it into the `TELELEO_API_KEY` environment variable.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from teleleo import Teleleo
|
|
56
|
+
|
|
57
|
+
client = Teleleo() # reads TELELEO_API_KEY
|
|
58
|
+
|
|
59
|
+
for dongle in client.dongles.list():
|
|
60
|
+
print(dongle.dongle_id, dongle.name, dongle.number)
|
|
61
|
+
|
|
62
|
+
sms = client.sms.send(
|
|
63
|
+
1234, # dongle_id of the modem that sends the SMS
|
|
64
|
+
number="+447700900123",
|
|
65
|
+
message="Hello from Teleleo",
|
|
66
|
+
)
|
|
67
|
+
print(sms.sms_id, sms.sms_status_id)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
### Read incoming SMS
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from datetime import datetime, timedelta, timezone
|
|
76
|
+
|
|
77
|
+
from teleleo import Teleleo
|
|
78
|
+
from teleleo.types import SmsType
|
|
79
|
+
|
|
80
|
+
client = Teleleo()
|
|
81
|
+
|
|
82
|
+
since = datetime.now(timezone.utc) - timedelta(days=1)
|
|
83
|
+
for sms in client.sms.list(sms_type_ids=[SmsType.INCOMING], from_=since, limit=100):
|
|
84
|
+
print(sms.created_at, sms.number_caller, sms.message_decoded)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Dates in answers are timezone-aware `datetime` objects in UTC. Date arguments take a `datetime` (a naive one is taken as UTC) or a string in the API format, `YYYY-MM-DD HH:MM:SS`.
|
|
88
|
+
|
|
89
|
+
### Pagination
|
|
90
|
+
|
|
91
|
+
List methods return a page. `page.items` holds one page; iterating the page goes through every item and requests the next pages as needed.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
page = client.contacts.list(limit=50)
|
|
95
|
+
print(page.total_count, len(page.items))
|
|
96
|
+
|
|
97
|
+
for contact in page: # all contacts, 50 per request
|
|
98
|
+
print(contact.name)
|
|
99
|
+
|
|
100
|
+
while page.has_next_page(): # or page by page
|
|
101
|
+
page = page.get_next_page()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Without `page` and `limit` the API returns the whole list in one answer (mailings return the first 50).
|
|
105
|
+
|
|
106
|
+
### Modem commands
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
client.dongles.reboot(1234)
|
|
110
|
+
info = client.dongles.get_network_info(1234)
|
|
111
|
+
print(info.current_network_name, info.network_type, info.is_roaming)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Every method and its arguments are listed in [api.md](api.md).
|
|
115
|
+
|
|
116
|
+
### Errors
|
|
117
|
+
|
|
118
|
+
Every error is a subclass of `teleleo.TeleleoError`. When the API answers with an error, the exception carries the machine-readable code in `error_message`, details in `error_details` and `request_id` for support.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import teleleo
|
|
122
|
+
from teleleo import Teleleo
|
|
123
|
+
|
|
124
|
+
client = Teleleo()
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
client.contacts.get(999999)
|
|
128
|
+
except teleleo.NotFoundError as e:
|
|
129
|
+
print("No such contact:", e.error_message)
|
|
130
|
+
except teleleo.BadRequestError as e:
|
|
131
|
+
print(e.status_code, e.error_message, e.error_details)
|
|
132
|
+
except teleleo.APIStatusError as e:
|
|
133
|
+
print("Teleleo error", e.status_code, e.error_message, "request_id:", e.request_id)
|
|
134
|
+
except teleleo.APIConnectionError:
|
|
135
|
+
print("Teleleo is unreachable")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| Status | Exception |
|
|
139
|
+
|---|---|
|
|
140
|
+
| 400 | `BadRequestError` |
|
|
141
|
+
| 400 with `*NOT_FOUND*`, 404 | `NotFoundError` |
|
|
142
|
+
| 401 | `AuthenticationError` |
|
|
143
|
+
| 403 | `PermissionDeniedError` |
|
|
144
|
+
| 409 | `ConflictError` |
|
|
145
|
+
| 429 | `RateLimitError` |
|
|
146
|
+
| 5xx | `InternalServerError` |
|
|
147
|
+
| no answer | `APIConnectionError`, `APITimeoutError` |
|
|
148
|
+
|
|
149
|
+
API v1 answers 400, not 404, for a missing object; the library raises `NotFoundError` for both, so your code keeps working when the API moves to 404.
|
|
150
|
+
|
|
151
|
+
### Retries and timeouts
|
|
152
|
+
|
|
153
|
+
Requests that failed for a transient reason are repeated twice with exponential backoff: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
client = Teleleo(timeout=20, max_retries=3)
|
|
157
|
+
client.with_options(timeout=5, max_retries=0).dongles.list()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The default timeout is 60 seconds.
|
|
161
|
+
|
|
162
|
+
### Async
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
import asyncio
|
|
166
|
+
|
|
167
|
+
from teleleo import AsyncTeleleo
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
async def main() -> None:
|
|
171
|
+
async with AsyncTeleleo() as client:
|
|
172
|
+
page = await client.sms.list(limit=100)
|
|
173
|
+
async for sms in page:
|
|
174
|
+
print(sms.message_decoded)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
asyncio.run(main())
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Configuration
|
|
181
|
+
|
|
182
|
+
| Argument | Environment variable | Default |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| `api_key` | `TELELEO_API_KEY` | required |
|
|
185
|
+
| `base_url` | `TELELEO_BASE_URL` | `https://app.teleleo.com/react_api` |
|
|
186
|
+
| `timeout` | | 60 seconds |
|
|
187
|
+
| `max_retries` | | 2 |
|
|
188
|
+
| `default_headers` | | |
|
|
189
|
+
| `http_client` | | your own `httpx.Client` / `httpx.AsyncClient`, for proxies or custom transports |
|
|
190
|
+
|
|
191
|
+
### Fields the library does not know yet
|
|
192
|
+
|
|
193
|
+
Answers are not validated, so a new field or enum value in the API never breaks your code: unknown fields are kept as attributes, unknown enum values stay plain integers. `model.to_dict()` and `model.to_json()` give the answer as it came. To send a parameter the library does not have yet, use `extra_query`, `extra_body` or `extra_headers` on any method.
|
|
194
|
+
|
|
195
|
+
## Versioning
|
|
196
|
+
|
|
197
|
+
The library follows [semver](https://semver.org/). Changes are listed in [CHANGELOG.md](CHANGELOG.md).
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
Models and resources in `src/teleleo/resources` and `src/teleleo/types` are generated from [`spec/openapi.yaml`](spec/openapi.yaml):
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pip install -e . -r requirements-dev.txt
|
|
205
|
+
python scripts/generate.py
|
|
206
|
+
pytest
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Support
|
|
210
|
+
|
|
211
|
+
support@teleleo.com · [teleleo.com](https://teleleo.com) · [issues](https://github.com/teleleo-com/teleleo-python/issues)
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
[MIT](LICENSE)
|
teleleo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Teleleo Python library
|
|
2
|
+
|
|
3
|
+
Teleleo is a platform for managing SIM-card modems from the cloud: SMS, calls, USSD, mailings, redirections, Wi-Fi, VPN and SOCKS proxy. `teleleo` is the official Python library for the [Teleleo REST API](https://github.com/teleleo-com/teleleo-openapi).
|
|
4
|
+
|
|
5
|
+
- Sync and async clients
|
|
6
|
+
- Typed models and enums for every answer, docstrings on every method
|
|
7
|
+
- Every error is an exception with the API error code
|
|
8
|
+
- Automatic pagination and retries
|
|
9
|
+
- Python 3.9+
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install teleleo
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
Take the API key in the Teleleo cabinet (Settings → API key) and put it into the `TELELEO_API_KEY` environment variable.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from teleleo import Teleleo
|
|
23
|
+
|
|
24
|
+
client = Teleleo() # reads TELELEO_API_KEY
|
|
25
|
+
|
|
26
|
+
for dongle in client.dongles.list():
|
|
27
|
+
print(dongle.dongle_id, dongle.name, dongle.number)
|
|
28
|
+
|
|
29
|
+
sms = client.sms.send(
|
|
30
|
+
1234, # dongle_id of the modem that sends the SMS
|
|
31
|
+
number="+447700900123",
|
|
32
|
+
message="Hello from Teleleo",
|
|
33
|
+
)
|
|
34
|
+
print(sms.sms_id, sms.sms_status_id)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Read incoming SMS
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from datetime import datetime, timedelta, timezone
|
|
43
|
+
|
|
44
|
+
from teleleo import Teleleo
|
|
45
|
+
from teleleo.types import SmsType
|
|
46
|
+
|
|
47
|
+
client = Teleleo()
|
|
48
|
+
|
|
49
|
+
since = datetime.now(timezone.utc) - timedelta(days=1)
|
|
50
|
+
for sms in client.sms.list(sms_type_ids=[SmsType.INCOMING], from_=since, limit=100):
|
|
51
|
+
print(sms.created_at, sms.number_caller, sms.message_decoded)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Dates in answers are timezone-aware `datetime` objects in UTC. Date arguments take a `datetime` (a naive one is taken as UTC) or a string in the API format, `YYYY-MM-DD HH:MM:SS`.
|
|
55
|
+
|
|
56
|
+
### Pagination
|
|
57
|
+
|
|
58
|
+
List methods return a page. `page.items` holds one page; iterating the page goes through every item and requests the next pages as needed.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
page = client.contacts.list(limit=50)
|
|
62
|
+
print(page.total_count, len(page.items))
|
|
63
|
+
|
|
64
|
+
for contact in page: # all contacts, 50 per request
|
|
65
|
+
print(contact.name)
|
|
66
|
+
|
|
67
|
+
while page.has_next_page(): # or page by page
|
|
68
|
+
page = page.get_next_page()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Without `page` and `limit` the API returns the whole list in one answer (mailings return the first 50).
|
|
72
|
+
|
|
73
|
+
### Modem commands
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
client.dongles.reboot(1234)
|
|
77
|
+
info = client.dongles.get_network_info(1234)
|
|
78
|
+
print(info.current_network_name, info.network_type, info.is_roaming)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Every method and its arguments are listed in [api.md](api.md).
|
|
82
|
+
|
|
83
|
+
### Errors
|
|
84
|
+
|
|
85
|
+
Every error is a subclass of `teleleo.TeleleoError`. When the API answers with an error, the exception carries the machine-readable code in `error_message`, details in `error_details` and `request_id` for support.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import teleleo
|
|
89
|
+
from teleleo import Teleleo
|
|
90
|
+
|
|
91
|
+
client = Teleleo()
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
client.contacts.get(999999)
|
|
95
|
+
except teleleo.NotFoundError as e:
|
|
96
|
+
print("No such contact:", e.error_message)
|
|
97
|
+
except teleleo.BadRequestError as e:
|
|
98
|
+
print(e.status_code, e.error_message, e.error_details)
|
|
99
|
+
except teleleo.APIStatusError as e:
|
|
100
|
+
print("Teleleo error", e.status_code, e.error_message, "request_id:", e.request_id)
|
|
101
|
+
except teleleo.APIConnectionError:
|
|
102
|
+
print("Teleleo is unreachable")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Status | Exception |
|
|
106
|
+
|---|---|
|
|
107
|
+
| 400 | `BadRequestError` |
|
|
108
|
+
| 400 with `*NOT_FOUND*`, 404 | `NotFoundError` |
|
|
109
|
+
| 401 | `AuthenticationError` |
|
|
110
|
+
| 403 | `PermissionDeniedError` |
|
|
111
|
+
| 409 | `ConflictError` |
|
|
112
|
+
| 429 | `RateLimitError` |
|
|
113
|
+
| 5xx | `InternalServerError` |
|
|
114
|
+
| no answer | `APIConnectionError`, `APITimeoutError` |
|
|
115
|
+
|
|
116
|
+
API v1 answers 400, not 404, for a missing object; the library raises `NotFoundError` for both, so your code keeps working when the API moves to 404.
|
|
117
|
+
|
|
118
|
+
### Retries and timeouts
|
|
119
|
+
|
|
120
|
+
Requests that failed for a transient reason are repeated twice with exponential backoff: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
client = Teleleo(timeout=20, max_retries=3)
|
|
124
|
+
client.with_options(timeout=5, max_retries=0).dongles.list()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The default timeout is 60 seconds.
|
|
128
|
+
|
|
129
|
+
### Async
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import asyncio
|
|
133
|
+
|
|
134
|
+
from teleleo import AsyncTeleleo
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
async def main() -> None:
|
|
138
|
+
async with AsyncTeleleo() as client:
|
|
139
|
+
page = await client.sms.list(limit=100)
|
|
140
|
+
async for sms in page:
|
|
141
|
+
print(sms.message_decoded)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
asyncio.run(main())
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Configuration
|
|
148
|
+
|
|
149
|
+
| Argument | Environment variable | Default |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `api_key` | `TELELEO_API_KEY` | required |
|
|
152
|
+
| `base_url` | `TELELEO_BASE_URL` | `https://app.teleleo.com/react_api` |
|
|
153
|
+
| `timeout` | | 60 seconds |
|
|
154
|
+
| `max_retries` | | 2 |
|
|
155
|
+
| `default_headers` | | |
|
|
156
|
+
| `http_client` | | your own `httpx.Client` / `httpx.AsyncClient`, for proxies or custom transports |
|
|
157
|
+
|
|
158
|
+
### Fields the library does not know yet
|
|
159
|
+
|
|
160
|
+
Answers are not validated, so a new field or enum value in the API never breaks your code: unknown fields are kept as attributes, unknown enum values stay plain integers. `model.to_dict()` and `model.to_json()` give the answer as it came. To send a parameter the library does not have yet, use `extra_query`, `extra_body` or `extra_headers` on any method.
|
|
161
|
+
|
|
162
|
+
## Versioning
|
|
163
|
+
|
|
164
|
+
The library follows [semver](https://semver.org/). Changes are listed in [CHANGELOG.md](CHANGELOG.md).
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
Models and resources in `src/teleleo/resources` and `src/teleleo/types` are generated from [`spec/openapi.yaml`](spec/openapi.yaml):
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pip install -e . -r requirements-dev.txt
|
|
172
|
+
python scripts/generate.py
|
|
173
|
+
pytest
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Support
|
|
177
|
+
|
|
178
|
+
support@teleleo.com · [teleleo.com](https://teleleo.com) · [issues](https://github.com/teleleo-com/teleleo-python/issues)
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
[MIT](LICENSE)
|
teleleo-0.1.0/api.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# API reference
|
|
2
|
+
|
|
3
|
+
Every method of `Teleleo` and `AsyncTeleleo`, generated from [`spec/openapi.yaml`](spec/openapi.yaml). `AsyncTeleleo` has the same methods; they are coroutines and return `AsyncPage` instead of `SyncPage`.
|
|
4
|
+
|
|
5
|
+
Models and enums are importable from `teleleo.types`.
|
|
6
|
+
|
|
7
|
+
## `client.dongles`
|
|
8
|
+
|
|
9
|
+
Modems of the account and their commands: reboot, Wi-Fi, Wi-Fi extender, number, network info.
|
|
10
|
+
|
|
11
|
+
| Method | HTTP | Returns | Description |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| `list(**params)` | `GET /dongle` | `SyncPage[DongleListItem]` | List modems |
|
|
14
|
+
| `reboot(dongle_id)` | `POST /dongle/{dongle_id}/reboot` | `bool` | Reboot modem |
|
|
15
|
+
| `enable_wifi(dongle_id)` | `POST /dongle/{dongle_id}/wifi/enable` | `bool` | Enable modem Wi-Fi |
|
|
16
|
+
| `disable_wifi(dongle_id)` | `POST /dongle/{dongle_id}/wifi/disable` | `bool` | Disable modem Wi-Fi |
|
|
17
|
+
| `set_wifi_credentials(dongle_id, hotspot_name=…, hotspot_password=…)` | `POST /dongle/{dongle_id}/wifi/credentials` | `bool` | Set modem Wi-Fi credentials |
|
|
18
|
+
| `enable_wifi_extender(dongle_id, ssid=…, password=…, wifi_extender_mode=…)` | `POST /dongle/{dongle_id}/wifi-extender/enable` | `bool` | Enable Wi-Fi extender |
|
|
19
|
+
| `disable_wifi_extender(dongle_id)` | `POST /dongle/{dongle_id}/wifi-extender/disable` | `bool` | Disable Wi-Fi extender |
|
|
20
|
+
| `scan_wifi_networks(dongle_id)` | `POST /dongle/{dongle_id}/wifi-extender/networks` | `bool` | Scan Wi-Fi networks |
|
|
21
|
+
| `update_offline_notification(dongle_id, is_enabled=…)` | `PUT /dongle/{dongle_id}/setting/offline-notification` | `bool` | Set offline notification |
|
|
22
|
+
| `set_number(dongle_id, number=…)` | `PUT /dongle/{dongle_id}/number` | `bool` | Set modem number |
|
|
23
|
+
| `get(dongle_id)` | `GET /dongle/{dongle_id}` | `Dongle` | Get modem |
|
|
24
|
+
| `update(dongle_id, **params)` | `PUT /dongle/{dongle_id}` | `Dongle` | Update modem |
|
|
25
|
+
| `get_network_info(dongle_id)` | `POST /dongle/{dongle_id}/mobile-network-info` | `DongleNetworkInfo` | Get modem network info |
|
|
26
|
+
| `get_sim_identifiers(dongle_id)` | `POST /dongle/{dongle_id}/mobile-network-ids` | `DongleSimIdentifiers` | Get modem SIM identifiers |
|
|
27
|
+
| `list_statistics(dongle_id, **params)` | `GET /dongle/{dongle_id}/statistic` | `List[DongleStatistic]` | List modem traffic statistics |
|
|
28
|
+
|
|
29
|
+
## `client.sms`
|
|
30
|
+
|
|
31
|
+
SMS of the modems: history, sending, replies, threads.
|
|
32
|
+
|
|
33
|
+
| Method | HTTP | Returns | Description |
|
|
34
|
+
|---|---|---|---|
|
|
35
|
+
| `send(dongle_id, number=…, message=…, **params)` | `POST /dongle/{dongle_id}/outgoing-sms` | `Sms` | Send SMS |
|
|
36
|
+
| `send_to_contact(dongle_id, contact_id=…, message=…, **params)` | `POST /dongle/{dongle_id}/outgoing-contact-sms` | `Sms` | Send SMS to contact |
|
|
37
|
+
| `reply(dongle_id, replied_to_sms_id=…, message=…, **params)` | `POST /dongle/{dongle_id}/reply-sms` | `Sms` | Reply to SMS |
|
|
38
|
+
| `list_threads(**params)` | `GET /sms/thread` | `SyncPage[SmsThread]` | List SMS threads |
|
|
39
|
+
| `list(**params)` | `GET /sms` | `SyncPage[Sms]` | List SMS |
|
|
40
|
+
| `list_for_dongle(dongle_id, **params)` | `GET /dongle/{dongle_id}/sms` | `SyncPage[Sms]` | List modem SMS |
|
|
41
|
+
| `get(dongle_id, sms_id)` | `GET /dongle/{dongle_id}/sms/{sms_id}` | `Sms` | Get SMS |
|
|
42
|
+
| `update(dongle_id, sms_id, **params)` | `PUT /dongle/{dongle_id}/sms/{sms_id}` | `Sms` | Update SMS |
|
|
43
|
+
| `delete(dongle_id, sms_id)` | `DELETE /dongle/{dongle_id}/sms/{sms_id}` | `None` | Delete SMS |
|
|
44
|
+
|
|
45
|
+
## `client.calls`
|
|
46
|
+
|
|
47
|
+
Calls of the modems: history, outgoing calls.
|
|
48
|
+
|
|
49
|
+
| Method | HTTP | Returns | Description |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `list(**params)` | `GET /call` | `SyncPage[Call]` | List calls |
|
|
52
|
+
| `create(dongle_id, **params)` | `POST /dongle/{dongle_id}/call` | `Call` | Make call |
|
|
53
|
+
| `get(dongle_id, call_id)` | `GET /dongle/{dongle_id}/call/{call_id}` | `Call` | Get call |
|
|
54
|
+
| `delete(dongle_id, call_id)` | `DELETE /dongle/{dongle_id}/call/{call_id}` | `None` | Delete call |
|
|
55
|
+
|
|
56
|
+
## `client.ussd`
|
|
57
|
+
|
|
58
|
+
USSD requests through a modem.
|
|
59
|
+
|
|
60
|
+
| Method | HTTP | Returns | Description |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `list(dongle_id, **params)` | `GET /dongle/{dongle_id}/ussd` | `SyncPage[Ussd]` | List USSD requests |
|
|
63
|
+
| `send(dongle_id, command=…)` | `POST /dongle/{dongle_id}/ussd` | `Ussd` | Send USSD |
|
|
64
|
+
| `get(dongle_id, ussd_id)` | `GET /dongle/{dongle_id}/ussd/{ussd_id}` | `Ussd` | Get USSD request |
|
|
65
|
+
| `delete(dongle_id, ussd_id)` | `DELETE /dongle/{dongle_id}/ussd/{ussd_id}` | `bool` | Delete USSD request |
|
|
66
|
+
| `delete_all(dongle_id)` | `DELETE /dongle/{dongle_id}/ussds` | `bool` | Delete USSD history |
|
|
67
|
+
|
|
68
|
+
## `client.contacts`
|
|
69
|
+
|
|
70
|
+
Address book of the account.
|
|
71
|
+
|
|
72
|
+
| Method | HTTP | Returns | Description |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| `list(**params)` | `GET /contact` | `SyncPage[Contact]` | List contacts |
|
|
75
|
+
| `create(phone=…, name=…, contact_group_ids=…, **params)` | `POST /contact` | `Contact` | Create contact |
|
|
76
|
+
| `get(contact_id)` | `GET /contact/{contact_id}` | `Contact` | Get contact |
|
|
77
|
+
| `update(contact_id, phone=…, name=…, contact_group_ids=…, **params)` | `PUT /contact/{contact_id}` | `Contact` | Update contact |
|
|
78
|
+
| `delete(contact_id)` | `DELETE /contact/{contact_id}` | `bool` | Delete contact |
|
|
79
|
+
| `import_contacts(data=…, **params)` | `POST /contact/import` | `ContactImportResult` | Import contacts |
|
|
80
|
+
|
|
81
|
+
## `client.contact_groups`
|
|
82
|
+
|
|
83
|
+
Groups of contacts, used by mailings, call scenarios and redirections.
|
|
84
|
+
|
|
85
|
+
| Method | HTTP | Returns | Description |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| `list(**params)` | `GET /contact-group` | `SyncPage[ContactGroup]` | List contact groups |
|
|
88
|
+
| `create(name=…, contact_ids=…)` | `POST /contact-group` | `ContactGroup` | Create contact group |
|
|
89
|
+
| `get(contact_group_id)` | `GET /contact-group/{contact_group_id}` | `ContactGroup` | Get contact group |
|
|
90
|
+
| `update(contact_group_id, name=…, contact_ids=…)` | `PUT /contact-group/{contact_group_id}` | `ContactGroup` | Update contact group |
|
|
91
|
+
| `delete(contact_group_id)` | `DELETE /contact-group/{contact_group_id}` | `bool` | Delete contact group |
|
|
92
|
+
|
|
93
|
+
## `client.mailings`
|
|
94
|
+
|
|
95
|
+
Bulk SMS and call campaigns.
|
|
96
|
+
|
|
97
|
+
| Method | HTTP | Returns | Description |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `list(**params)` | `GET /mailing` | `SyncPage[Mailing]` | List mailings |
|
|
100
|
+
| `create(name=…, mailing_type_id=…, mailing_entity_type_id=…, dongle_id=…, **params)` | `POST /mailing` | `Mailing` | Create mailing |
|
|
101
|
+
| `create_sms(name=…, text=…, mailing_type_id=…, dongle_id=…, **params)` | `POST /mailing/sms` | `Mailing` | Create SMS mailing |
|
|
102
|
+
| `create_call(name=…, mailing_type_id=…, dongle_id=…, **params)` | `POST /mailing/call` | `Mailing` | Create call mailing |
|
|
103
|
+
| `get(mailing_id)` | `GET /mailing/{mailing_id}` | `Mailing` | Get mailing |
|
|
104
|
+
| `update(mailing_id, **params)` | `PUT /mailing/{mailing_id}` | `Mailing` | Update mailing |
|
|
105
|
+
| `delete(mailing_id)` | `DELETE /mailing/{mailing_id}` | `bool` | Delete mailing |
|
|
106
|
+
|
|
107
|
+
## `client.redirections`
|
|
108
|
+
|
|
109
|
+
Rules for incoming SMS and calls: forwarding, auto reply, HTTP callback.
|
|
110
|
+
|
|
111
|
+
| Method | HTTP | Returns | Description |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `list(**params)` | `GET /redirection` | `SyncPage[Redirection]` | List redirections |
|
|
114
|
+
| `create(condition=…, name=…, params=…, redirection_type_id=…)` | `POST /redirection` | `Redirection` | Create redirection |
|
|
115
|
+
| `get(redirection_id)` | `GET /redirection/{redirection_id}` | `Redirection` | Get redirection |
|
|
116
|
+
| `update(redirection_id, condition=…, name=…, params=…, redirection_type_id=…)` | `PUT /redirection/{redirection_id}` | `Redirection` | Update redirection |
|
|
117
|
+
| `delete(redirection_id)` | `DELETE /redirection/{redirection_id}` | `bool` | Delete redirection |
|
|
118
|
+
|
|
119
|
+
## `client.call_scenarios`
|
|
120
|
+
|
|
121
|
+
What a modem plays to incoming callers.
|
|
122
|
+
|
|
123
|
+
| Method | HTTP | Returns | Description |
|
|
124
|
+
|---|---|---|---|
|
|
125
|
+
| `list(**params)` | `GET /call-scenario` | `SyncPage[CallScenario]` | List call scenarios |
|
|
126
|
+
| `create(name=…, is_call_record=…, dongle_id=…, call_scenario_type_id=…, tmp_file_id=…, **params)` | `POST /call-scenario` | `CallScenario` | Create call scenario |
|
|
127
|
+
| `get(call_scenario_id)` | `GET /call-scenario/{call_scenario_id}` | `CallScenario` | Get call scenario |
|
|
128
|
+
| `update(call_scenario_id, **params)` | `PUT /call-scenario/{call_scenario_id}` | `CallScenario` | Update call scenario |
|
|
129
|
+
| `delete(call_scenario_id)` | `DELETE /call-scenario/{call_scenario_id}` | `bool` | Delete call scenario |
|
|
130
|
+
| `retry(call_scenario_id)` | `POST /call-scenario/{call_scenario_id}/retry` | `CallScenario` | Retry call scenario delivery |
|
|
131
|
+
|
|
132
|
+
## `client.follow_up_sms_settings`
|
|
133
|
+
|
|
134
|
+
SMS a modem sends to a caller after a call.
|
|
135
|
+
|
|
136
|
+
| Method | HTTP | Returns | Description |
|
|
137
|
+
|---|---|---|---|
|
|
138
|
+
| `list(**params)` | `GET /follow-up-sms-setting` | `SyncPage[FollowUpSmsSetting]` | List follow-up SMS settings |
|
|
139
|
+
| `create(dongle_id=…, name=…, text=…, **params)` | `POST /follow-up-sms-setting` | `FollowUpSmsSetting` | Create follow-up SMS setting |
|
|
140
|
+
| `get(follow_up_sms_setting_id)` | `GET /follow-up-sms-setting/{follow_up_sms_setting_id}` | `FollowUpSmsSetting` | Get follow-up SMS setting |
|
|
141
|
+
| `update(follow_up_sms_setting_id, dongle_id=…, name=…, text=…, **params)` | `PUT /follow-up-sms-setting/{follow_up_sms_setting_id}` | `FollowUpSmsSetting` | Update follow-up SMS setting |
|
|
142
|
+
| `delete(follow_up_sms_setting_id)` | `DELETE /follow-up-sms-setting/{follow_up_sms_setting_id}` | `bool` | Delete follow-up SMS setting |
|
|
143
|
+
|
|
144
|
+
## `client.public_vpn`
|
|
145
|
+
|
|
146
|
+
VPN access through a modem.
|
|
147
|
+
|
|
148
|
+
| Method | HTTP | Returns | Description |
|
|
149
|
+
|---|---|---|---|
|
|
150
|
+
| `enable(dongle_id)` | `POST /dongle/{dongle_id}/public-vpn/enable` | `bool` | Enable public VPN |
|
|
151
|
+
| `disable(dongle_id)` | `POST /dongle/{dongle_id}/public-vpn/disable` | `bool` | Disable public VPN |
|
|
152
|
+
| `refresh_password(dongle_id)` | `POST /dongle/{dongle_id}/public-vpn/refresh-password` | `bool` | Refresh public VPN password |
|
|
153
|
+
| `list_sessions()` | `GET /public-vpn/connect-session-list` | `List[PublicVpnSession]` | List public VPN sessions |
|
|
154
|
+
|
|
155
|
+
## `client.socks_proxies`
|
|
156
|
+
|
|
157
|
+
SOCKS5 proxy through the mobile network of a modem.
|
|
158
|
+
|
|
159
|
+
| Method | HTTP | Returns | Description |
|
|
160
|
+
|---|---|---|---|
|
|
161
|
+
| `list(**params)` | `GET /dongle-socks-proxy` | `SyncPage[DongleSocksProxy]` | List SOCKS proxies |
|
|
162
|
+
| `create(dongle_id=…, password=…, allowed_ips=…)` | `POST /dongle-socks-proxy` | `DongleSocksProxy` | Create SOCKS proxy |
|
|
163
|
+
| `get(dongle_socks_proxy_id)` | `GET /dongle-socks-proxy/{dongle_socks_proxy_id}` | `DongleSocksProxy` | Get SOCKS proxy |
|
|
164
|
+
| `update(dongle_socks_proxy_id, password=…, allowed_ips=…)` | `PUT /dongle-socks-proxy/{dongle_socks_proxy_id}` | `DongleSocksProxy` | Update SOCKS proxy |
|
|
165
|
+
| `delete(dongle_socks_proxy_id)` | `DELETE /dongle-socks-proxy/{dongle_socks_proxy_id}` | `bool` | Delete SOCKS proxy |
|
|
166
|
+
|
|
167
|
+
## `client.sip_users`
|
|
168
|
+
|
|
169
|
+
SIP accounts of the modems.
|
|
170
|
+
|
|
171
|
+
| Method | HTTP | Returns | Description |
|
|
172
|
+
|---|---|---|---|
|
|
173
|
+
| `list(**params)` | `GET /sip-user` | `List[PbxSipUser]` | List SIP users |
|
|
174
|
+
| `get(sip_user_id)` | `GET /sip-user/{sip_user_id}` | `PbxSipUser` | Get SIP user |
|
|
175
|
+
|
|
176
|
+
## `client.files`
|
|
177
|
+
|
|
178
|
+
Downloads, temporary audio uploads and text-to-speech.
|
|
179
|
+
|
|
180
|
+
| Method | HTTP | Returns | Description |
|
|
181
|
+
|---|---|---|---|
|
|
182
|
+
| `download(file_id)` | `GET /file/{file_id}` | `bytes` | Get file |
|
|
183
|
+
| `download_tmp(file_id)` | `GET /file/tmp/{file_id}` | `bytes` | Get temporary file |
|
|
184
|
+
| `upload_tmp(file_base64=…, file_name=…, **params)` | `POST /file/upload-tmp` | `TmpFile` | Upload temporary file |
|
|
185
|
+
| `generate_speech(text=…, voice=…, language=…)` | `POST /file/generate-speech` | `TmpFile` | Generate speech |
|