CTyun ZOS SDK
A boto3-compatible SDK for CTyun Object Storage (ZOS) with httpx backend. This SDK provides both synchronous and asynchronous interfaces for interacting with CTyun's S3-compatible object storage service.
Features
- boto3-compatible API: Familiar interface for developers already using AWS S3
- Dual interfaces: Both synchronous and asynchronous clients
- httpx backend: Modern HTTP client with better performance and features
- CTyun-specific optimizations: Handles CTyun ZOS service requirements
- Proper signing: AWS SigV4 authentication with CTyun-specific header handling
- Type hints: Full type annotations for better development experience
Installation
From PyPI (recommended)
pip install ctyun-zos-sdk
From source
git clone https://github.com/your-org/ctyun-zos-sdk.git
cd ctyun-zos-sdk
pip install -e .
Quick Start
Basic Usage
import os
from ctyun_zos_sdk import ZOSSession
# Create a session
session = ZOSSession(
aws_access_key_id=os.environ["S3_ACCESS_KEY"],
aws_secret_access_key=os.environ["S3_SECRET_KEY"],
region_name="huabei-2",
endpoint_url="https://huabei-2.zos.ctyun.cn"
)
# Get S3 client
s3_client = session.client('s3')
# Upload a file
response = s3_client.put_object(
Bucket="your-bucket",
Key="example/test.txt",
Body="Hello, CTyun ZOS!",
ContentType="text/plain"
)
print(f"Upload successful! ETag: {response['ETag']}")
# Download a file
response = s3_client.get_object(
Bucket="your-bucket",
Key="example/test.txt"
)
print(f"Content: {response['Body'].decode('utf-8')}")
Asynchronous Usage
import asyncio
import os
from ctyun_zos_sdk import AsyncZOSClient
async def main():
async with AsyncZOSClient(
access_key=os.environ["S3_ACCESS_KEY"],
secret_key=os.environ["S3_SECRET_KEY"],
region="huabei-2",
endpoint="https://huabei-2.zos.ctyun.cn"
) as client:
# Upload file asynchronously
response = await client.put_object(
Bucket="your-bucket",
Key="async-test.txt",
Body="Async upload content"
)
print(f"Upload successful! ETag: {response['ETag']}")
# Run the async function
asyncio.run(main())
Direct Client Usage
from ctyun_zos_sdk import ZOSClient
# Create client directly
client = ZOSClient(
access_key="your_access_key",
secret_key="your_secret_key",
region="huabei-2",
endpoint="https://huabei-2.zos.ctyun.cn"
)
# Use context manager for automatic cleanup
with client:
response = client.put_object(
Bucket="your-bucket",
Key="direct-test.txt",
Body="Direct client usage"
)
print(f"Upload successful! ETag: {response['ETag']}")
Configuration
Environment Variables
You can configure the SDK using environment variables:
export S3_ACCESS_KEY="your_access_key"
export S3_SECRET_KEY="your_secret_key"
export S3_REGION="huabei-2"
export S3_ENDPOINT="https://huabei-2.zos.ctyun.cn"
Supported Regions
huabei-2- 华北2huadong-1- 华东1huadong-2- 华东2huanan-1- 华南1huanan-2- 华南2
API Reference
ZOSSession
The main session class for managing configuration and creating clients.
session = ZOSSession(
aws_access_key_id="your_key",
aws_secret_access_key="your_secret",
region_name="huabei-2",
endpoint_url="https://huabei-2.zos.ctyun.cn"
)
# Create S3 client
s3_client = session.client('s3')
ZOSClient
Synchronous client for S3 operations.
Methods
get_object(Bucket, Key, **kwargs)- Download an objectput_object(Bucket, Key, Body, **kwargs)- Upload an objectdelete_object(Bucket, Key, **kwargs)- Delete an objectlist_objects_v2(Bucket, Prefix="", **kwargs)- List objects in a bucket
Parameters
Bucket(str): Bucket nameKey(str): Object keyBody(str/bytes/file): Object content for uploadsContentType(str): MIME type of the objectMetadata(dict): Custom metadata for the object
AsyncZOSClient
Asynchronous client with the same interface as ZOSClient.
async with AsyncZOSClient(...) as client:
response = await client.put_object(...)
response = await client.get_object(...)
Examples
See the examples/ directory for more detailed examples:
examples/basic_usage.py- Basic synchronous operationsexamples/async_usage.py- Asynchronous operations and concurrency
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/your-org/ctyun-zos-sdk.git
cd ctyun-zos-sdk
# Install development dependencies
make install-dev
# Install package in development mode
make dev-install
Running Tests
# Run all tests
make test
# Run tests with coverage
make test-cov
# Run linting checks
make lint
# Format code
make format
Building and Publishing
# Build package
make build
# Check package metadata
make check
# Upload to test PyPI
make upload-test
# Upload to PyPI
make upload
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Based on the verified examples in the
verified/directory - Uses boto3's authentication and signing mechanisms
- Built with httpx for modern HTTP client capabilities
Support
For issues and questions:
- Create an issue on GitHub
- Check the examples in the
examples/directory - Review the verified examples in the
verified/directory
Metadata
Release files for ctyun-zos-sdk 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ctyun_zos_sdk-0.3.0.tar.gz | 25.0 kB | Without provenance | Details for ctyun_zos_sdk-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctyun_zos_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ctyun_zos_sdk-0.3.0-py3-none-any.whl |
Total release size: 44.5 kB
Release files / ctyun_zos_sdk-0.3.0.tar.gz
| Download URL | ctyun_zos_sdk-0.3.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d9771969975505e636993881f078489128e7d9ffe5a2abb848a000167f75cde
|
|
BLAKE2b-256 checksum How to use checksums |
5a39f9d4b30c806cbb949aa34de0f535c304cf3d49b64f180f2cc09e29ba3454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / ctyun_zos_sdk-0.3.0-py3-none-any.whl
| Download URL | ctyun_zos_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
18714a2215d293c92703e9f8c926d6654b4fccb106e248741b153996d0224cef
|
|
BLAKE2b-256 checksum How to use checksums |
4898b954c6d3788808aa81361f0d77f3d8b592bc6b0cadc49c5ab8340f08b3bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Security for ctyun-zos-sdk 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.