sed-sh 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.
Files changed (42) hide show
  1. sed_sh-0.1.0/LICENSE +21 -0
  2. sed_sh-0.1.0/MANIFEST.in +5 -0
  3. sed_sh-0.1.0/PKG-INFO +492 -0
  4. sed_sh-0.1.0/README.md +452 -0
  5. sed_sh-0.1.0/examples/async_example.py +197 -0
  6. sed_sh-0.1.0/examples/inbox_example.py +96 -0
  7. sed_sh-0.1.0/examples/links_example.py +45 -0
  8. sed_sh-0.1.0/examples/malware_example.py +58 -0
  9. sed_sh-0.1.0/examples/reports_example.py +221 -0
  10. sed_sh-0.1.0/examples/routes_example.py +134 -0
  11. sed_sh-0.1.0/pyproject.toml +77 -0
  12. sed_sh-0.1.0/sed_sh/__init__.py +34 -0
  13. sed_sh-0.1.0/sed_sh/async_client.py +137 -0
  14. sed_sh-0.1.0/sed_sh/cli.py +369 -0
  15. sed_sh-0.1.0/sed_sh/client.py +118 -0
  16. sed_sh-0.1.0/sed_sh/config.py +136 -0
  17. sed_sh-0.1.0/sed_sh/exceptions.py +105 -0
  18. sed_sh-0.1.0/sed_sh/services/__init__.py +1 -0
  19. sed_sh-0.1.0/sed_sh/services/async_base.py +157 -0
  20. sed_sh-0.1.0/sed_sh/services/async_inbox.py +32 -0
  21. sed_sh-0.1.0/sed_sh/services/async_links.py +65 -0
  22. sed_sh-0.1.0/sed_sh/services/async_malware.py +75 -0
  23. sed_sh-0.1.0/sed_sh/services/async_reports.py +109 -0
  24. sed_sh-0.1.0/sed_sh/services/async_routes.py +196 -0
  25. sed_sh-0.1.0/sed_sh/services/base.py +158 -0
  26. sed_sh-0.1.0/sed_sh/services/inbox.py +149 -0
  27. sed_sh-0.1.0/sed_sh/services/links.py +103 -0
  28. sed_sh-0.1.0/sed_sh/services/malware.py +95 -0
  29. sed_sh-0.1.0/sed_sh/services/reports.py +206 -0
  30. sed_sh-0.1.0/sed_sh/services/routes.py +261 -0
  31. sed_sh-0.1.0/sed_sh.egg-info/PKG-INFO +492 -0
  32. sed_sh-0.1.0/sed_sh.egg-info/SOURCES.txt +40 -0
  33. sed_sh-0.1.0/sed_sh.egg-info/dependency_links.txt +1 -0
  34. sed_sh-0.1.0/sed_sh.egg-info/entry_points.txt +2 -0
  35. sed_sh-0.1.0/sed_sh.egg-info/requires.txt +16 -0
  36. sed_sh-0.1.0/sed_sh.egg-info/top_level.txt +1 -0
  37. sed_sh-0.1.0/setup.cfg +4 -0
  38. sed_sh-0.1.0/setup.py +5 -0
  39. sed_sh-0.1.0/tests/test_async_client.py +57 -0
  40. sed_sh-0.1.0/tests/test_client.py +51 -0
  41. sed_sh-0.1.0/tests/test_exceptions.py +65 -0
  42. sed_sh-0.1.0/tests/test_services_integration.py +69 -0
sed_sh-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 sed.sh
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.
@@ -0,0 +1,5 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include sed_sh *.py
5
+ recursive-include examples *.py
sed_sh-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,492 @@
1
+ Metadata-Version: 2.4
2
+ Name: sed-sh
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for sed.sh API - URL shortening, malware scanning, disposable email, mock APIs, and PDF reports
5
+ Author-email: "sed.sh" <support@sed.sh>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.sed.sh
8
+ Project-URL: Documentation, https://www.sed.sh/docs
9
+ Project-URL: Repository, https://github.com/triellocom/sed-sh-sdk/tree/master/python
10
+ Project-URL: Issues, https://github.com/triellocom/sed-sh-sdk/issues
11
+ Keywords: sed.sh,url-shortener,malware-scanner,disposable-email,mock-api,pdf-generator,api-client
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Internet :: WWW/HTTP
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.25.0
27
+ Requires-Dist: aiohttp>=3.8.0
28
+ Requires-Dist: aiofiles>=23.0.0
29
+ Requires-Dist: click>=8.0.0
30
+ Requires-Dist: typing-extensions>=4.0.0; python_version < "3.10"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
33
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
34
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
+ Requires-Dist: black>=23.0.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
38
+ Requires-Dist: types-requests>=2.25.0; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # sed.sh Python SDK
42
+
43
+ Official Python client library for [sed.sh](https://www.sed.sh) API - providing URL shortening, malware scanning, disposable email, mock APIs, and PDF report generation.
44
+
45
+ [![PyPI version](https://badge.fury.io/py/sed-sh.svg)](https://badge.fury.io/py/sed-sh)
46
+ [![Python Versions](https://img.shields.io/pypi/pyversions/sed-sh.svg)](https://pypi.org/project/sed-sh/)
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
48
+
49
+ ## Features
50
+
51
+ - **Links**: Create, manage, and track shortened URLs with optional password protection
52
+ - **Malware Scanner**: Scan files for malware using AWS GuardDuty
53
+ - **Disposable Inbox**: Create temporary email addresses for testing
54
+ - **Mock APIs**: Create mock HTTP endpoints for testing and development
55
+ - **PDF Reports**: Generate PDF documents from HTML templates with JSON data
56
+ - **Both Sync and Async**: Full support for synchronous and asynchronous operations
57
+ - **CLI Tool**: Command-line interface for all services
58
+ - **Type Hints**: Full typing support for better IDE autocomplete
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install sed-sh
64
+ ```
65
+
66
+ ## Quick Start
67
+
68
+ ### Synchronous Usage
69
+
70
+ ```python
71
+ from sed_sh import SedSH
72
+
73
+ # Initialize client with API key
74
+ client = SedSH(api_key="your_api_key_here")
75
+
76
+ # Create a short link
77
+ link = client.links.create("https://example.com/very/long/url")
78
+ print(f"Short URL: {link['shortUrl']}")
79
+
80
+ # Scan a file for malware
81
+ scan = client.malware.scan_file("/path/to/file.pdf")
82
+ print(f"Scan status: {scan['status']}")
83
+
84
+ # Create a disposable inbox
85
+ inbox = client.inbox.create()
86
+ print(f"Email address: {inbox['email']}")
87
+
88
+ # Create a mock API endpoint
89
+ endpoint = client.routes.create_endpoint(
90
+ name="Test API",
91
+ method="POST",
92
+ path="/api/test",
93
+ response_status=200,
94
+ response_body='{"success": true}'
95
+ )
96
+ print(f"Mock URL: {endpoint['url']}")
97
+
98
+ # Generate a PDF from template
99
+ template = client.reports.create_template(
100
+ name="Invoice",
101
+ html="<h1>Invoice for {{customer}}</h1>"
102
+ )
103
+ pdf = client.reports.generate_pdf(
104
+ template['templateId'],
105
+ {"customer": "John Doe"}
106
+ )
107
+ print(f"PDF URL: {pdf['downloadUrl']}")
108
+ ```
109
+
110
+ ### Asynchronous Usage
111
+
112
+ ```python
113
+ import asyncio
114
+ from sed_sh import AsyncSedSH
115
+
116
+ async def main():
117
+ # Initialize async client
118
+ client = AsyncSedSH(api_key="your_api_key_here")
119
+
120
+ # Create a short link
121
+ link = await client.links.create("https://example.com")
122
+ print(f"Short URL: {link['shortUrl']}")
123
+
124
+ # Scan a file
125
+ scan = await client.malware.scan_file("/path/to/file.pdf")
126
+ print(f"Scan status: {scan['status']}")
127
+
128
+ # Close the session when done
129
+ await client.close()
130
+
131
+ asyncio.run(main())
132
+ ```
133
+
134
+ ### Using Context Managers
135
+
136
+ ```python
137
+ # Sync context manager
138
+ with SedSH(api_key="your_api_key") as client:
139
+ link = client.links.create("https://example.com")
140
+ print(link['shortUrl'])
141
+
142
+ # Async context manager
143
+ async with AsyncSedSH(api_key="your_api_key") as client:
144
+ link = await client.links.create("https://example.com")
145
+ print(link['shortUrl'])
146
+ ```
147
+
148
+ ## Authentication
149
+
150
+ The SDK supports multiple authentication methods:
151
+
152
+ ### 1. Constructor Parameter
153
+ ```python
154
+ client = SedSH(api_key="your_api_key")
155
+ ```
156
+
157
+ ### 2. Environment Variable
158
+ ```bash
159
+ export SEDSH_API_KEY="your_api_key"
160
+ ```
161
+ ```python
162
+ client = SedSH() # Automatically uses SEDSH_API_KEY
163
+ ```
164
+
165
+ ### 3. Config File
166
+ Create `~/.sedsh/config.json`:
167
+ ```json
168
+ {
169
+ "api_key": "your_api_key",
170
+ "base_url": "https://api.sed.sh"
171
+ }
172
+ ```
173
+ ```python
174
+ client = SedSH() # Automatically loads from config file
175
+ ```
176
+
177
+ ## CLI Usage
178
+
179
+ The SDK includes a command-line interface:
180
+
181
+ ```bash
182
+ # Set API key
183
+ export SEDSH_API_KEY="your_api_key"
184
+
185
+ # Links
186
+ sedsh links create https://example.com
187
+ sedsh links create https://example.com --password secret123
188
+ sedsh links list
189
+ sedsh links delete abc12
190
+
191
+ # Malware
192
+ sedsh malware scan /path/to/file.pdf
193
+
194
+ # Inbox
195
+ sedsh inbox create
196
+ sedsh inbox list
197
+ sedsh inbox messages <inbox-code>
198
+ sedsh inbox delete <inbox-code>
199
+
200
+ # Routes
201
+ sedsh routes create "Test API" POST /api/test --status 200 --body '{"ok": true}'
202
+ sedsh routes list
203
+ sedsh routes delete <endpoint-id>
204
+
205
+ # Reports
206
+ sedsh reports create-template "Invoice" /path/to/template.html
207
+ sedsh reports generate <template-id> '{"customer": "John"}'
208
+ sedsh reports list-templates
209
+ ```
210
+
211
+ ## API Reference
212
+
213
+ ### Links Service
214
+
215
+ ```python
216
+ # Create a link
217
+ link = client.links.create(
218
+ target_url="https://example.com",
219
+ password="optional_password" # Optional
220
+ )
221
+
222
+ # List all links
223
+ links = client.links.list()
224
+
225
+ # Delete a link
226
+ client.links.delete(code="abc12")
227
+ ```
228
+
229
+ ### Malware Service
230
+
231
+ ```python
232
+ # Scan a file
233
+ scan = client.malware.scan_file(
234
+ file_path="/path/to/file.pdf"
235
+ )
236
+ # Returns: {'scanId': '...', 'status': 'pending', 'fileName': '...'}
237
+
238
+ # Note: Scan results are sent via email notification
239
+ ```
240
+
241
+ ### Inbox Service
242
+
243
+ ```python
244
+ # Create an inbox
245
+ inbox = client.inbox.create()
246
+
247
+ # List all inboxes
248
+ inboxes = client.inbox.list()
249
+
250
+ # Get messages for an inbox
251
+ messages = client.inbox.get_messages(inbox_code="inbox_123")
252
+
253
+ # Get a specific message
254
+ message = client.inbox.get_message(
255
+ inbox_code="inbox_123",
256
+ message_id="msg_456"
257
+ )
258
+
259
+ # Delete a message
260
+ client.inbox.delete_message(
261
+ inbox_code="inbox_123",
262
+ message_id="msg_456"
263
+ )
264
+
265
+ # Delete an inbox
266
+ client.inbox.delete(inbox_code="inbox_123")
267
+ ```
268
+
269
+ ### Routes Service
270
+
271
+ ```python
272
+ # Create a mock endpoint
273
+ endpoint = client.routes.create_endpoint(
274
+ name="User API",
275
+ method="POST",
276
+ path="/api/users",
277
+ response_status=200,
278
+ response_body='{"success": true}',
279
+ response_headers={"Content-Type": "application/json"}, # Optional
280
+ response_delay=0, # Optional, milliseconds
281
+ enabled=True # Optional
282
+ )
283
+
284
+ # Create a forward endpoint (proxy mode)
285
+ endpoint = client.routes.create_endpoint(
286
+ name="Proxy API",
287
+ method="GET",
288
+ path="/api/proxy",
289
+ forward_mode=True,
290
+ forward_url="https://api.example.com/endpoint"
291
+ )
292
+
293
+ # List endpoints
294
+ endpoints = client.routes.list_endpoints()
295
+
296
+ # Update an endpoint
297
+ updated = client.routes.update_endpoint(
298
+ endpoint_id="endpoint_123",
299
+ name="Updated API",
300
+ response_status=201
301
+ )
302
+
303
+ # Toggle endpoint enabled/disabled
304
+ client.routes.toggle_endpoint(
305
+ endpoint_id="endpoint_123",
306
+ enabled=False
307
+ )
308
+
309
+ # Get requests received by endpoints
310
+ requests = client.routes.get_requests()
311
+
312
+ # Get details of a specific request
313
+ request_details = client.routes.get_request(request_id="req_123")
314
+
315
+ # Delete an endpoint
316
+ client.routes.delete_endpoint(endpoint_id="endpoint_123")
317
+ ```
318
+
319
+ ### Reports Service
320
+
321
+ ```python
322
+ # Create a template
323
+ template = client.reports.create_template(
324
+ name="Invoice Template",
325
+ html="<h1>Invoice #{{invoice_number}}</h1>",
326
+ expiry_hours=24 # Optional, max 24
327
+ )
328
+
329
+ # List templates
330
+ templates = client.reports.list_templates()
331
+
332
+ # Get template HTML
333
+ html = client.reports.get_template(template_id="tpl_123")
334
+
335
+ # Generate PDF from template
336
+ pdf = client.reports.generate_pdf(
337
+ template_id="tpl_123",
338
+ data={
339
+ "invoice_number": "INV-001",
340
+ "customer": "John Doe",
341
+ "amount": "$100.00"
342
+ }
343
+ )
344
+ # Returns: {'downloadUrl': '...', 'generationId': '...', 'expiresAt': ...}
345
+
346
+ # List recent PDF generations
347
+ generations = client.reports.list_generations()
348
+
349
+ # Delete a template
350
+ client.reports.delete_template(template_id="tpl_123")
351
+ ```
352
+
353
+ ## Error Handling
354
+
355
+ ```python
356
+ from sed_sh import SedSH
357
+ from sed_sh.exceptions import (
358
+ SedSHError,
359
+ AuthenticationError,
360
+ RateLimitError,
361
+ ResourceNotFoundError,
362
+ InvalidRequestError,
363
+ )
364
+
365
+ client = SedSH(api_key="your_api_key")
366
+
367
+ try:
368
+ link = client.links.create("https://example.com")
369
+ except AuthenticationError as e:
370
+ print(f"Invalid API key: {e}")
371
+ except RateLimitError as e:
372
+ print(f"Rate limit exceeded: {e}")
373
+ except ResourceNotFoundError as e:
374
+ print(f"Resource not found: {e}")
375
+ except InvalidRequestError as e:
376
+ print(f"Invalid request: {e}")
377
+ except SedSHError as e:
378
+ print(f"API error: {e}")
379
+ ```
380
+
381
+ ## Important Notes
382
+
383
+ ⚠️ **This SDK does NOT include automatic retries or request timeouts**. You should implement these in your application if needed:
384
+
385
+ ```python
386
+ # Example: Manual retry logic
387
+ from time import sleep
388
+
389
+ def create_link_with_retry(client, url, max_retries=3):
390
+ for attempt in range(max_retries):
391
+ try:
392
+ return client.links.create(url)
393
+ except SedSHError as e:
394
+ if attempt == max_retries - 1:
395
+ raise
396
+ sleep(2 ** attempt) # Exponential backoff
397
+ ```
398
+
399
+ ⚠️ **This SDK does NOT perform client-side input validation**. Invalid inputs will be caught by the API and return appropriate errors.
400
+
401
+ ## Configuration Options
402
+
403
+ ```python
404
+ client = SedSH(
405
+ api_key="your_api_key", # API key (required if not in env/config)
406
+ base_url="https://api.sed.sh", # API base URL (optional)
407
+ timeout=30, # Request timeout in seconds (optional)
408
+ )
409
+ ```
410
+
411
+ ## Development
412
+
413
+ ```bash
414
+ # Clone the repository
415
+ git clone https://github.com/triellocom/sed-sh-sdk.git
416
+ cd sed-sh-sdk/python
417
+
418
+ # Install in development mode
419
+ pip install -e ".[dev]"
420
+
421
+ # Run tests
422
+ pytest
423
+
424
+ # Format code
425
+ black sed_sh/
426
+
427
+ # Type checking
428
+ mypy sed_sh/
429
+ ```
430
+
431
+ ## Examples
432
+
433
+ See the [`examples/`](./examples) directory for complete examples:
434
+
435
+ - `links_sync.py` - Synchronous link management
436
+ - `links_async.py` - Asynchronous link management
437
+ - `malware_sync.py` - File scanning
438
+ - `inbox_sync.py` - Disposable email management
439
+ - `routes_sync.py` - Mock API endpoint creation
440
+ - `reports_sync.py` - PDF generation
441
+
442
+ ## Requirements
443
+
444
+ - Python 3.8 or higher
445
+ - `requests` >= 2.25.0
446
+ - `aiohttp` >= 3.8.0
447
+ - `click` >= 8.0.0
448
+
449
+ ## License
450
+
451
+ MIT License - see [LICENSE](LICENSE) file for details.
452
+
453
+ ## Support
454
+
455
+ - Documentation: https://www.sed.sh/docs
456
+ - Issues: https://github.com/triellocom/sed-sh-sdk/issues
457
+ - Email: support@sed.sh
458
+
459
+ ## Links
460
+
461
+ - Website: https://www.sed.sh
462
+ - API Documentation: https://www.sed.sh/docs
463
+ - PyPI: https://pypi.org/project/sed-sh/
464
+
465
+ ## Testing
466
+
467
+ The SDK includes a comprehensive test suite using pytest.
468
+
469
+ ### Running Tests
470
+
471
+ ```bash
472
+ # Install development dependencies
473
+ pip install -e .[dev]
474
+
475
+ # Run all tests
476
+ make test
477
+
478
+ # Run with coverage
479
+ make test-cov
480
+
481
+ # Run integration tests (requires API key)
482
+ export SEDSH_API_KEY="your-api-key"
483
+ make test-integration
484
+ ```
485
+
486
+ ### Test Structure
487
+
488
+ - `tests/test_exceptions.py` - Exception handling tests
489
+ - `tests/test_client.py` - Client initialization tests
490
+ - `tests/test_services_integration.py` - API integration tests
491
+
492
+ See [README_TESTING.md](README_TESTING.md) for detailed testing documentation.