Reusable helper library for the Cloud Task Manager serverless application.
Project description
cloud-task-utils
A lightweight, stdlib-only Python utility library for the Cloud Task Manager serverless application. Designed to run inside AWS Lambda without any additional dependencies.
Installation
pip install cloud-task-utils
Quick Start
from cloud_task_utils import TaskUtils, ResponseBuilder, ValidationError
utils = TaskUtils()
resp = ResponseBuilder()
# Generate a unique task ID
task_id = utils.generate_task_id()
print(task_id) # e.g. "550e8400-e29b-41d4-a716-446655440000"
# Validate user input — raises ValidationError on failure
try:
name = utils.validate_task_name(" Write unit tests ")
print(name) # "Write unit tests"
except ValidationError as exc:
print(exc)
# Build an API Gateway v2 response
response = resp.created({"task_id": task_id, "message": "Task created."})
# {"statusCode": 201, "headers": {...}, "body": "{...}"}
# Calculate a DynamoDB TTL (7 days from now)
ttl = utils.ttl_from_days(7)
API
TaskUtils
| Method | Description |
|---|---|
generate_task_id() |
Returns a UUID v4 string |
validate_task_name(name) |
Validates and strips a task name; raises on error |
parse_priority(raw) |
Normalises priority to low/medium/high/critical |
utc_now_iso() |
Returns current UTC time as ISO 8601 string |
ttl_from_days(days) |
Returns Unix epoch TTL days from now |
format_task_summary(task) |
Returns a readable single-line task summary |
ResponseBuilder
| Method | Status | Description |
|---|---|---|
ok(body) |
200 | Standard success |
created(body) |
201 | Resource created |
bad_request(message) |
400 | Validation failure |
not_found(message) |
404 | Resource not found |
server_error(message) |
500 | Internal error |
All responses include CORS headers compatible with S3-hosted frontends.
ValidationError
Raised by TaskUtils when caller input fails validation. The message is
safe to surface directly in API error responses.
Licence
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloud_task_utils-1.0.0.tar.gz.
File metadata
- Download URL: cloud_task_utils-1.0.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c0fae933cfdb21c278844eaeffe6cfd243a719c8aae6459e9671d4cbf87e29a
|
|
| MD5 |
e1633a1408d242356b283faaccff861a
|
|
| BLAKE2b-256 |
a531189c163412b011ece3f13ee23eeed1b62f9d5ae23d5ce4e97a4c80d5f7c6
|
File details
Details for the file cloud_task_utils-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cloud_task_utils-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ab27695bc90dd167353989a759295f5b6cbbdaa53fa8f814106c1537c810a7e
|
|
| MD5 |
b148a0377ea3f1dd3df1296a5a4504fe
|
|
| BLAKE2b-256 |
5a45a7169e75f45a60be1bc9be81f91ecbfebf427580e5d4a826788f9e38a943
|