No project description provided
Project description
Lightwheel SDK Python
A Python SDK for interacting with the Lightwheel API, featuring comprehensive logging capabilities.
Features
- Authentication Management: Secure login/logout with token caching and refresh
- Comprehensive Logging: Detailed logging throughout the SDK for debugging and monitoring
- CLI Interface: Command-line tools for easy interaction
- Error Handling: Robust exception handling with detailed error logging
Installation
pip install lightwheel-sdk
Quick Start
Basic Usage
from lightwheel_sdk.loader import LightwheelClient
# Initialize client
client = LightwheelClient(host="https://api.lightwheel.net")
# Login
client.login(username="your_username", password="your_password")
# Make API calls
response = client.post("/api/your/endpoint", data={"key": "value"})
CLI Usage
# Login
lightwheel login --username your_username --password your_password
# Logout
lightwheel logout
Logging Configuration
The SDK includes comprehensive logging capabilities that can be configured through environment variables or programmatically.
Environment Variables
LW_SDK_LOG_LEVEL: Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)LW_SDK_LOG_FILE: Optional path to log fileLW_API_ENDPOINT: API endpoint URL
Programmatic Configuration
from lightwheel_sdk.logger import setup_logger
# Configure logger
logger = setup_logger(
name="my_app",
level="DEBUG",
log_file="/path/to/logfile.log"
)
Logging Levels
- DEBUG: Detailed information for debugging
- INFO: General information about SDK operations
- WARNING: Warning messages for potential issues
- ERROR: Error messages for failed operations
- CRITICAL: Critical errors that may cause the application to stop
Log Categories
The SDK uses different logger names for different components:
lightwheel_sdk.client: Client operations and API callslightwheel_sdk.login: Authentication and login managementlightwheel_sdk.cli: Command-line interface operationslightwheel_sdk.exception: Exception handling and error logging
Example Log Output
2025-01-27 10:30:15,123 - lightwheel_sdk.client - INFO - Initializing LightwheelClient with host: https://api.lightwheel.net
2025-01-27 10:30:15,124 - lightwheel_sdk.client - INFO - Starting login process
2025-01-27 10:30:15,125 - lightwheel_sdk.client - INFO - Performing authentication with API
2025-01-27 10:30:15,200 - lightwheel_sdk.client - INFO - Login successful for user: john_doe
2025-01-27 10:30:15,201 - lightwheel_sdk.client - DEBUG - Making POST request to /api/your/endpoint
2025-01-27 10:30:15,250 - lightwheel_sdk.client - DEBUG - POST request to /api/your/endpoint completed successfully
API Reference
LightwheelClient
Main client class for interacting with the Lightwheel API.
Methods
login(force_login=False, username=None, password=None): Authenticate with the APIlogout(): Clear authentication and remove cached credentialspost(path, data=None, timeout=None): Make POST requests to the API
Login Manager
High-level interface for authentication management.
Methods
login(force_login=False, username=None, password=None): Login to the APIlogout(): Logout from the APIget_headers(): Get authentication headers
Error Handling
The SDK provides comprehensive error handling with detailed logging:
ApiException: API-related errors with status codes and response detailsAuthenticationFailedException: Authentication failuresUnknownException: Unexpected errors
All exceptions include detailed logging for debugging purposes.
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
LW_API_ENDPOINT |
API endpoint URL | https://api.lightwheel.net |
LW_SDK_LOG_LEVEL |
Logging level | INFO |
LW_SDK_LOG_FILE |
Log file path | None (console only) |
LW_SDK_HEADERS_* |
Custom headers | None |
LoaderUserName |
Username for authentication | None |
LoaderToken |
Token for authentication | None |
Custom Headers
You can set custom headers using environment variables with the prefix LW_SDK_HEADERS_:
export LW_SDK_HEADERS_X_CUSTOM_HEADER="custom_value"
Development
Running Tests
python -m pytest tests/
Building
python -m build
License
Copyright 2025 Lightwheel Team
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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 Distributions
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 lightwheel_sdk-0.19-py3-none-any.whl.
File metadata
- Download URL: lightwheel_sdk-0.19-py3-none-any.whl
- Upload date:
- Size: 74.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98548df2d4064fb57c1017a030eed21f2a6293c0b263e4c02ebf22845c103fae
|
|
| MD5 |
46b5815ec033bef2ebfe21ca2135f53c
|
|
| BLAKE2b-256 |
3ac464865b08a8faa1493a5f065b3aafa15d652093b0cbd2bbd3ccfe371b2324
|