ctyun-zos-sdk


Namectyun-zos-sdk JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA boto3-compatible SDK for CTyun Object Storage (ZOS) with httpx backend
upload_time2025-09-01 07:31:01
maintainerNone
docs_urlNone
authorLiu Xin
requires_python>=3.8
licenseMIT
keywords ctyun zos object-storage s3 boto3 httpx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CTyun ZOS SDK

[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![PyPI](https://img.shields.io/badge/pypi-ctyun--zos--sdk-blue.svg)](https://pypi.org/project/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)

```bash
pip install ctyun-zos-sdk
```

### From source

```bash
git clone https://github.com/your-org/ctyun-zos-sdk.git
cd ctyun-zos-sdk
pip install -e .
```

## Quick Start

### Basic Usage

```python
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

```python
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

```python
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:

```bash
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` - 华北2
- `huadong-1` - 华东1
- `huadong-2` - 华东2
- `huanan-1` - 华南1
- `huanan-2` - 华南2

## API Reference

### ZOSSession

The main session class for managing configuration and creating clients.

```python
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 object
- `put_object(Bucket, Key, Body, **kwargs)` - Upload an object
- `delete_object(Bucket, Key, **kwargs)` - Delete an object
- `list_objects_v2(Bucket, Prefix="", **kwargs)` - List objects in a bucket

#### Parameters

- `Bucket` (str): Bucket name
- `Key` (str): Object key
- `Body` (str/bytes/file): Object content for uploads
- `ContentType` (str): MIME type of the object
- `Metadata` (dict): Custom metadata for the object

### AsyncZOSClient

Asynchronous client with the same interface as ZOSClient.

```python
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 operations
- `examples/async_usage.py` - Asynchronous operations and concurrency

## Development

### Setup Development Environment

```bash
# 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

```bash
# Run all tests
make test

# Run tests with coverage
make test-cov

# Run linting checks
make lint

# Format code
make format
```

### Building and Publishing

```bash
# Build package
make build

# Check package metadata
make check

# Upload to test PyPI
make upload-test

# Upload to PyPI
make upload
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request

## License

This project is licensed under the MIT License - see the [LICENSE](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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ctyun-zos-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "ctyun, zos, object-storage, s3, boto3, httpx",
    "author": "Liu Xin",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/35/da/5d05d20375d8147b43d580ab158302ce95cd02323ad9145b6dfaa92480ea/ctyun_zos_sdk-0.1.2.tar.gz",
    "platform": null,
    "description": "# CTyun ZOS SDK\n\n[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![PyPI](https://img.shields.io/badge/pypi-ctyun--zos--sdk-blue.svg)](https://pypi.org/project/ctyun-zos-sdk/)\n\nA 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.\n\n## Features\n\n- **boto3-compatible API**: Familiar interface for developers already using AWS S3\n- **Dual interfaces**: Both synchronous and asynchronous clients\n- **httpx backend**: Modern HTTP client with better performance and features\n- **CTyun-specific optimizations**: Handles CTyun ZOS service requirements\n- **Proper signing**: AWS SigV4 authentication with CTyun-specific header handling\n- **Type hints**: Full type annotations for better development experience\n\n## Installation\n\n### From PyPI (recommended)\n\n```bash\npip install ctyun-zos-sdk\n```\n\n### From source\n\n```bash\ngit clone https://github.com/your-org/ctyun-zos-sdk.git\ncd ctyun-zos-sdk\npip install -e .\n```\n\n## Quick Start\n\n### Basic Usage\n\n```python\nimport os\nfrom ctyun_zos_sdk import ZOSSession\n\n# Create a session\nsession = ZOSSession(\n    aws_access_key_id=os.environ[\"S3_ACCESS_KEY\"],\n    aws_secret_access_key=os.environ[\"S3_SECRET_KEY\"],\n    region_name=\"huabei-2\",\n    endpoint_url=\"https://huabei-2.zos.ctyun.cn\"\n)\n\n# Get S3 client\ns3_client = session.client('s3')\n\n# Upload a file\nresponse = s3_client.put_object(\n    Bucket=\"your-bucket\",\n    Key=\"example/test.txt\",\n    Body=\"Hello, CTyun ZOS!\",\n    ContentType=\"text/plain\"\n)\nprint(f\"Upload successful! ETag: {response['ETag']}\")\n\n# Download a file\nresponse = s3_client.get_object(\n    Bucket=\"your-bucket\",\n    Key=\"example/test.txt\"\n)\nprint(f\"Content: {response['Body'].decode('utf-8')}\")\n```\n\n### Asynchronous Usage\n\n```python\nimport asyncio\nimport os\nfrom ctyun_zos_sdk import AsyncZOSClient\n\nasync def main():\n    async with AsyncZOSClient(\n        access_key=os.environ[\"S3_ACCESS_KEY\"],\n        secret_key=os.environ[\"S3_SECRET_KEY\"],\n        region=\"huabei-2\",\n        endpoint=\"https://huabei-2.zos.ctyun.cn\"\n    ) as client:\n        \n        # Upload file asynchronously\n        response = await client.put_object(\n            Bucket=\"your-bucket\",\n            Key=\"async-test.txt\",\n            Body=\"Async upload content\"\n        )\n        print(f\"Upload successful! ETag: {response['ETag']}\")\n\n# Run the async function\nasyncio.run(main())\n```\n\n### Direct Client Usage\n\n```python\nfrom ctyun_zos_sdk import ZOSClient\n\n# Create client directly\nclient = ZOSClient(\n    access_key=\"your_access_key\",\n    secret_key=\"your_secret_key\",\n    region=\"huabei-2\",\n    endpoint=\"https://huabei-2.zos.ctyun.cn\"\n)\n\n# Use context manager for automatic cleanup\nwith client:\n    response = client.put_object(\n        Bucket=\"your-bucket\",\n        Key=\"direct-test.txt\",\n        Body=\"Direct client usage\"\n    )\n    print(f\"Upload successful! ETag: {response['ETag']}\")\n```\n\n## Configuration\n\n### Environment Variables\n\nYou can configure the SDK using environment variables:\n\n```bash\nexport S3_ACCESS_KEY=\"your_access_key\"\nexport S3_SECRET_KEY=\"your_secret_key\"\nexport S3_REGION=\"huabei-2\"\nexport S3_ENDPOINT=\"https://huabei-2.zos.ctyun.cn\"\n```\n\n### Supported Regions\n\n- `huabei-2` - \u534e\u53172\n- `huadong-1` - \u534e\u4e1c1\n- `huadong-2` - \u534e\u4e1c2\n- `huanan-1` - \u534e\u53571\n- `huanan-2` - \u534e\u53572\n\n## API Reference\n\n### ZOSSession\n\nThe main session class for managing configuration and creating clients.\n\n```python\nsession = ZOSSession(\n    aws_access_key_id=\"your_key\",\n    aws_secret_access_key=\"your_secret\",\n    region_name=\"huabei-2\",\n    endpoint_url=\"https://huabei-2.zos.ctyun.cn\"\n)\n\n# Create S3 client\ns3_client = session.client('s3')\n```\n\n### ZOSClient\n\nSynchronous client for S3 operations.\n\n#### Methods\n\n- `get_object(Bucket, Key, **kwargs)` - Download an object\n- `put_object(Bucket, Key, Body, **kwargs)` - Upload an object\n- `delete_object(Bucket, Key, **kwargs)` - Delete an object\n- `list_objects_v2(Bucket, Prefix=\"\", **kwargs)` - List objects in a bucket\n\n#### Parameters\n\n- `Bucket` (str): Bucket name\n- `Key` (str): Object key\n- `Body` (str/bytes/file): Object content for uploads\n- `ContentType` (str): MIME type of the object\n- `Metadata` (dict): Custom metadata for the object\n\n### AsyncZOSClient\n\nAsynchronous client with the same interface as ZOSClient.\n\n```python\nasync with AsyncZOSClient(...) as client:\n    response = await client.put_object(...)\n    response = await client.get_object(...)\n```\n\n## Examples\n\nSee the `examples/` directory for more detailed examples:\n\n- `examples/basic_usage.py` - Basic synchronous operations\n- `examples/async_usage.py` - Asynchronous operations and concurrency\n\n## Development\n\n### Setup Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/your-org/ctyun-zos-sdk.git\ncd ctyun-zos-sdk\n\n# Install development dependencies\nmake install-dev\n\n# Install package in development mode\nmake dev-install\n```\n\n### Running Tests\n\n```bash\n# Run all tests\nmake test\n\n# Run tests with coverage\nmake test-cov\n\n# Run linting checks\nmake lint\n\n# Format code\nmake format\n```\n\n### Building and Publishing\n\n```bash\n# Build package\nmake build\n\n# Check package metadata\nmake check\n\n# Upload to test PyPI\nmake upload-test\n\n# Upload to PyPI\nmake upload\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Ensure all tests pass\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Based on the verified examples in the `verified/` directory\n- Uses boto3's authentication and signing mechanisms\n- Built with httpx for modern HTTP client capabilities\n\n## Support\n\nFor issues and questions:\n\n- Create an issue on GitHub\n- Check the examples in the `examples/` directory\n- Review the verified examples in the `verified/` directory\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A boto3-compatible SDK for CTyun Object Storage (ZOS) with httpx backend",
    "version": "0.1.2",
    "project_urls": {
        "Documentation": "https://e.gitee.com/zgcai/repos/zgcai/ctyun-zos-sdk/blob/master/README.md",
        "Homepage": "https://e.gitee.com/zgcai/repos/zgcai/ctyun-zos-sdk",
        "Issues": "https://e.gitee.com/zgcai/repos/zgcai/ctyun-zos-sdk/issues/table",
        "Repository": "https://e.gitee.com/zgcai/repos/zgcai/ctyun-zos-sdk"
    },
    "split_keywords": [
        "ctyun",
        " zos",
        " object-storage",
        " s3",
        " boto3",
        " httpx"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "38c6734d755d2c0f79b302cd539144a926c8398658289f7f24f8183601a663b9",
                "md5": "d4a3a3d926ecad37bac33c66252b9089",
                "sha256": "d8d80b67c158cfb606e432fdd27f1a8074df8075307d32f35f1f0a901019fff0"
            },
            "downloads": -1,
            "filename": "ctyun_zos_sdk-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d4a3a3d926ecad37bac33c66252b9089",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14260,
            "upload_time": "2025-09-01T07:31:00",
            "upload_time_iso_8601": "2025-09-01T07:31:00.035801Z",
            "url": "https://files.pythonhosted.org/packages/38/c6/734d755d2c0f79b302cd539144a926c8398658289f7f24f8183601a663b9/ctyun_zos_sdk-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "35da5d05d20375d8147b43d580ab158302ce95cd02323ad9145b6dfaa92480ea",
                "md5": "08a2faffe555eb9ec14cb530880910ab",
                "sha256": "adb3fc912dd8285d9feab1bfe015757715e2a2c86feaa5ed869996c62b26f630"
            },
            "downloads": -1,
            "filename": "ctyun_zos_sdk-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "08a2faffe555eb9ec14cb530880910ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16716,
            "upload_time": "2025-09-01T07:31:01",
            "upload_time_iso_8601": "2025-09-01T07:31:01.323329Z",
            "url": "https://files.pythonhosted.org/packages/35/da/5d05d20375d8147b43d580ab158302ce95cd02323ad9145b6dfaa92480ea/ctyun_zos_sdk-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-01 07:31:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ctyun-zos-sdk"
}
        
Elapsed time: 0.46874s