Metadata-Version: 2.4
Name: yicloud-sdk-python
Version: 0.2.0
Summary: YiCloud OpenAPI SDK for Python
Author: YiCloud
Project-URL: Homepage, https://gitee.com/yicloud-team/openapi-sdk-python
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-cov>=3.0; extra == "test"
Requires-Dist: requests-mock>=1.10; extra == "test"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=3.0; extra == "dev"
Requires-Dist: requests-mock>=1.10; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Provides-Extra: lint
Requires-Dist: ruff>=0.1; extra == "lint"
Requires-Dist: mypy>=1.0; extra == "lint"
Dynamic: license-file

# OpenAPI SDK for Python

A Python SDK for the OpenAPI service.

## Installation

使用 pip 安装（推荐）:

```bash
pip install yicloud-sdk-python
```

从源码安装（不推荐）：
git clone https://gitee.com/yicloud-team/openapi-sdk-python.git
cd openapi-sdk-python
pip install -e .

## Configuration

The SDK reads configuration from environment variables:

| Variable | Default | Description |
|----------|---------|-------------|
| YICLOUD_API_HOST | https://gate.yicloud.com | API endpoint |
| YICLOUD_TIMEOUT | 30 | Timeout in seconds |
| YICLOUD_MAX_RETRIES | 0 | Max retry attempts |
| YICLOUD_PUBLIC_KEY | - | Access key (required) |
| YICLOUD_SECRET_KEY | - | Secret key (required) |

## Usage

```python
import yicloud.base as base
from yicloud.services import iam
from yicloud.base import msgs

# Create config (reads from env vars)
cfg = base.new_config()
cfg.log_level = base.log.Level.DEBUG
cfg.timeout = 10

# Create credential (reads from env vars)
credential = base.new_credential()

# Create client
client = base.new_client(
    base.with_config(cfg),
    base.with_credential(credential),
)

# Inject client into service
iam.use_client(client)

# Create metadata context
ctx, meta = msgs.new_meta_ctx()

# Call API
try:
    user_data = iam.get_user(ctx, iam.GetUserReq(UserName="admin"))
    print(f"成功返回: {user_data}, RequestID={meta.request_id}")
except base.exc.ServerException as e:
    print(f"后端错误: action={e.action}, code={e.code}, message={e.message}")
except base.exc.ClientException as e:
    print(f"客户端错误: action={e.action}")
except base.exc.YiCloudException as e:
    print(f"SDK 错误: {e}")
```

## Services

| Service | Package | Actions | Description |
|---------|---------|---------|-------------|
| BC | `yicloud.services.bc` | 5 | 账单管理 BC |
| Dataset | `yicloud.services.dataset` | 10 | 数据集 DATASET |
| FS | `yicloud.services.fs` | 8 | 文件系统 FS |
| IAM | `yicloud.services.iam` | 12 | 访问控制 IAM |
| Inferset | `yicloud.services.inferset` | 14 | 模型推理服务 INFERSET |
| JOB | `yicloud.services.job` | 13 | 训练任务 JOB |
| MC | `yicloud.services.mc` | 26 | 管理中心 MC |
| Modelrepo | `yicloud.services.modelrepo` | 11 | 模型仓库 MODELREPO |
| Monitor | `yicloud.services.monitor` | 1 | 监控中心 MONITOR |
| OSS | `yicloud.services.oss` | 5 | 对象存储OSS |
| RAY | `yicloud.services.ray` | 9 | 分布式计算 Ray |
| Registry | `yicloud.services.registry` | 12 | 镜像仓库 REGISTRY |
| Volume | `yicloud.services.volume` | 12 | 云盘管理 Volume |
| Workspace | `yicloud.services.workspace` | 21 | 开发机 WS |

## Project Structure

```
yicloud/                    # Main package
├── base/                   # Infrastructure
│   ├── client.py           # HTTP client (Get/Post)
│   ├── config.py           # Configuration
│   ├── exc.py              # Exception types
│   ├── auth/               # HMAC-SHA256 signing
│   ├── log/                # Logger
│   ├── msgs/               # Response types (Rsp[T], Header, RspMeta)
│   └── utils/              # Utilities
└── services/               # Business services (14 services)
    ├── bc/         # 账单管理 BC
    ├── dataset/    # 数据集 DATASET
    ├── fs/         # 文件系统 FS
    ├── iam/        # 访问控制 IAM
    ├── inferset/   # 模型推理服务 INFERSET
    ├── job/        # 训练任务 JOB
    ├── mc/         # 管理中心 MC
    ├── modelrepo/  # 模型仓库 MODELREPO
    ├── monitor/    # 监控中心 MONITOR
    ├── oss/        # 对象存储OSS
    ├── ray/        # 分布式计算 Ray
    ├── registry/   # 镜像仓库 REGISTRY
    ├── volume/     # 云盘管理 Volume
    ├── workspace/  # 开发机 WS
examples/                   # Example code (one per service)
```
