Skip to content

Commit c0faa77

Browse files
author
AxT-Team Bot
committed
chore: enable PyPI release
0 parents  commit c0faa77

File tree

858 files changed

+82647
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

858 files changed

+82647
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: release
2+
on:
3+
push:
4+
tags: ['v*.*.*']
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: '3.11'
15+
- run: pip install -U pip build
16+
- run: python -m build
17+
- name: Publish to PyPI
18+
uses: pypa/gh-action-pypi-publish@release/v1
19+
with:
20+
user: __token__
21+
password: ${{ secrets.PYPI_API_TOKEN }}
22+
- uses: softprops/action-gh-release@v2
23+
with:
24+
files: |
25+
dist/*
26+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-python@v5
9+
with: { python-version: '3.11' }
10+
- run: pip install -U pip wheel
11+
- run: pip install -e .[dev]
12+
- run: pytest tests -q

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
__pycache__/
2+
.dist/
3+
build/
4+
dist/
5+
*.egg-info
6+
.env
7+
.venv
8+
.idea/
9+
.vscode/

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# uapi-sdk-python
2+
3+
![Banner](./banner.png)
4+
5+
[![Python](https://img.shields.io/badge/Python-3.9+-3776AB?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
6+
[![Docs](https://img.shields.io/badge/Docs-uapis.cn-2EAE5D?style=flat-square)](https://uapis.cn/)
7+
8+
> [!NOTE]
9+
> 所有接口的 Python 示例都可以在 [UApi](https://uapis.cn/docs/introduction) 的接口文档页面,向下滚动至 **快速启动** 区块后直接复制。
10+
11+
## 快速开始
12+
13+
```bash
14+
pip install uapi-sdk-python
15+
```
16+
17+
```python
18+
from uapi import UapiClient
19+
20+
client = UapiClient("https://uapis.cn/api/v1")
21+
result = client.social.get_social_qq_userinfo(qq="10001")
22+
print(result)
23+
```
24+
25+
## 特性
26+
27+
现在你不再需要反反复复的查阅文档了。
28+
29+
只需在 IDE 中键入 `client.`,所有核心模块——如 `social``game``image`——即刻同步展现。进一步输入即可直接定位到 `get_social_qq_userinfo` 这样的具体方法,其名称与文档的 `operationId` 严格保持一致,确保了开发过程的直观与高效。
30+
31+
所有方法签名只接受真实且必需的参数。当你在构建请求时,IDE 会即时提示 `qq``username` 等键名,这彻底杜绝了在 `dict`/关键字参数中因拼写错误而导致的运行时错误。
32+
33+
针对 401、404、429 等标准 HTTP 响应,SDK 已将其统一映射为具名的异常类型。这些异常均附带 `code``status``details` 等关键上下文信息,确保你在日志中能第一时间准确、快速地诊断问题。
34+
35+
`UapiClient(base_url, token, timeout)` 默认使用 `httpx` 并自动追加 `Authorization` 头;需要切换环境或调整超时时,只要改一次构造参数即可。
36+
37+
如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
38+
39+
## 错误模型概览
40+
41+
| HTTP 状态码 | SDK 错误类型 | 附加信息 |
42+
|-------------|----------------------------------------------|------------------------------------------------------------------------------------|
43+
| 401/403 | `UnauthorizedError` | `code``status` |
44+
| 404 | `NotFoundError` / `NoMatchError` | `code``status` |
45+
| 400 | `InvalidParameterError` / `InvalidParamsError` | `code``status``details` |
46+
| 429 | `ServiceBusyError` | `code``status``retry_after_seconds`(用于决定何时重试) |
47+
| 5xx | `InternalServerErrorError` / `ApiErrorError` | `code``status``details` |
48+
| 其他 4xx | `UapiError` | `code``status``details` |
49+
50+
## 其他 SDK
51+
52+
| 语言 | 仓库地址 |
53+
|-------------|--------------------------------------------------------------|
54+
| Go | https://github.com/AxT-Team/uapi-go-sdk |
55+
| Python(当前) | https://github.com/AxT-Team/uapi-python-sdk |
56+
| TypeScript| https://github.com/AxT-Team/uapi-typescript-sdk |
57+
| Browser (TypeScript/JavaScript)| https://github.com/AxT-Team/uapi-browser-sdk |
58+
| Java | https://github.com/AxT-Team/uapi-java-sdk |
59+
| PHP | https://github.com/AxT-Team/uapi-php-sdk |
60+
| C# | https://github.com/AxT-Team/uapi-csharp-sdk |
61+
| C++ | https://github.com/AxT-Team/uapi-cpp-sdk |
62+
| Rust | https://github.com/AxT-Team/uapi-rust-sdk |
63+
64+
## 文档
65+
66+
访问 [UApi文档首页](https://uapis.cn/docs/introduction) 并选择任意接口,向下滚动到 **快速启动** 区块即可看到最新的 Python 示例代码。

banner.png

1.78 MB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# NOTE: This file is auto generated by OpenAPI Generator.
2+
# URL: https://openapi-generator.tech
3+
#
4+
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
5+
6+
name: uapi Python package
7+
8+
on: [push, pull_request]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r requirements.txt
31+
pip install -r test-requirements.txt
32+
- name: Test with pytest
33+
run: |
34+
pytest --cov=uapi

internal/.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
venv/
48+
.venv/
49+
.python-version
50+
.pytest_cache
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Django stuff:
57+
*.log
58+
59+
# Sphinx documentation
60+
docs/_build/
61+
62+
# PyBuilder
63+
target/
64+
65+
# Ipython Notebook
66+
.ipynb_checkpoints

internal/.gitlab-ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# NOTE: This file is auto generated by OpenAPI Generator.
2+
# URL: https://openapi-generator.tech
3+
#
4+
# ref: https://docs.gitlab.com/ee/ci/README.html
5+
# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
6+
7+
stages:
8+
- test
9+
10+
.pytest:
11+
stage: test
12+
script:
13+
- pip install -r requirements.txt
14+
- pip install -r test-requirements.txt
15+
- pytest --cov=uapi
16+
17+
pytest-3.9:
18+
extends: .pytest
19+
image: python:3.9-alpine
20+
pytest-3.10:
21+
extends: .pytest
22+
image: python:3.10-alpine
23+
pytest-3.11:
24+
extends: .pytest
25+
image: python:3.11-alpine
26+
pytest-3.12:
27+
extends: .pytest
28+
image: python:3.12-alpine
29+
pytest-3.13:
30+
extends: .pytest
31+
image: python:3.13-alpine

internal/.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

0 commit comments

Comments
 (0)