python-cnb 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_cnb-0.1.0/LICENSE +20 -0
- python_cnb-0.1.0/MANIFEST.in +2 -0
- python_cnb-0.1.0/PKG-INFO +102 -0
- python_cnb-0.1.0/README.md +65 -0
- python_cnb-0.1.0/cnb/__init__.py +7 -0
- python_cnb-0.1.0/cnb/artifactory.py +205 -0
- python_cnb-0.1.0/cnb/assets.py +219 -0
- python_cnb-0.1.0/cnb/build.py +91 -0
- python_cnb-0.1.0/cnb/client.py +79 -0
- python_cnb-0.1.0/cnb/cnb.py +46 -0
- python_cnb-0.1.0/cnb/collaborators.py +320 -0
- python_cnb-0.1.0/cnb/contributors.py +72 -0
- python_cnb-0.1.0/cnb/exceptions.py +21 -0
- python_cnb-0.1.0/cnb/followers.py +50 -0
- python_cnb-0.1.0/cnb/git.py +441 -0
- python_cnb-0.1.0/cnb/gitsettings.py +158 -0
- python_cnb-0.1.0/cnb/issues.py +233 -0
- python_cnb-0.1.0/cnb/missions.py +23 -0
- python_cnb-0.1.0/cnb/models/__init__.py +0 -0
- python_cnb-0.1.0/cnb/models/api.py +393 -0
- python_cnb-0.1.0/cnb/models/chart.py +43 -0
- python_cnb-0.1.0/cnb/models/constant.py +85 -0
- python_cnb-0.1.0/cnb/models/convert.py +13 -0
- python_cnb-0.1.0/cnb/models/die.py +19 -0
- python_cnb-0.1.0/cnb/models/dto.py +1523 -0
- python_cnb-0.1.0/cnb/models/git_woa_com_cnb_monorepo_git_internal_app_git_service_bff_api.py +14 -0
- python_cnb-0.1.0/cnb/models/git_woa_com_cnb_monorepo_git_internal_app_git_service_bff_web.py +14 -0
- python_cnb-0.1.0/cnb/models/git_woa_com_cnb_monorepo_git_internal_app_vcs_service_bff_api.py +13 -0
- python_cnb-0.1.0/cnb/models/git_woa_com_cnb_monorepo_git_internal_dto_web.py +14 -0
- python_cnb-0.1.0/cnb/models/git_woa_com_cnb_monorepo_mission_mission_resource_dto_web.py +13 -0
- python_cnb-0.1.0/cnb/models/handler.py +83 -0
- python_cnb-0.1.0/cnb/models/http.py +20 -0
- python_cnb-0.1.0/cnb/models/identity.py +19 -0
- python_cnb-0.1.0/cnb/models/label.py +15 -0
- python_cnb-0.1.0/cnb/models/map_constant.py +11 -0
- python_cnb-0.1.0/cnb/models/models.py +50 -0
- python_cnb-0.1.0/cnb/models/openapi.py +64 -0
- python_cnb-0.1.0/cnb/models/organization.py +16 -0
- python_cnb-0.1.0/cnb/models/organizations.py +18 -0
- python_cnb-0.1.0/cnb/models/scope.py +28 -0
- python_cnb-0.1.0/cnb/models/v1.py +26 -0
- python_cnb-0.1.0/cnb/models/web.py +1045 -0
- python_cnb-0.1.0/cnb/models/webapi.py +162 -0
- python_cnb-0.1.0/cnb/models/wechat.py +25 -0
- python_cnb-0.1.0/cnb/organizations.py +192 -0
- python_cnb-0.1.0/cnb/pulls.py +242 -0
- python_cnb-0.1.0/cnb/releases.py +170 -0
- python_cnb-0.1.0/cnb/repocontributor.py +31 -0
- python_cnb-0.1.0/cnb/repolabels.py +75 -0
- python_cnb-0.1.0/cnb/repositories.py +243 -0
- python_cnb-0.1.0/cnb/starring.py +58 -0
- python_cnb-0.1.0/cnb/users.py +73 -0
- python_cnb-0.1.0/cnb/workspace.py +66 -0
- python_cnb-0.1.0/pyproject.toml +3 -0
- python_cnb-0.1.0/python_cnb.egg-info/PKG-INFO +102 -0
- python_cnb-0.1.0/python_cnb.egg-info/SOURCES.txt +59 -0
- python_cnb-0.1.0/python_cnb.egg-info/dependency_links.txt +1 -0
- python_cnb-0.1.0/python_cnb.egg-info/requires.txt +3 -0
- python_cnb-0.1.0/python_cnb.egg-info/top_level.txt +1 -0
- python_cnb-0.1.0/setup.cfg +4 -0
- python_cnb-0.1.0/setup.py +39 -0
python_cnb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present, cnb.cool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the “Software”),
|
|
7
|
+
to deal in the Software without restriction, including without limitation
|
|
8
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
9
|
+
and/or sell copies of the Software, and to permit persons to whom
|
|
10
|
+
the Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
19
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-cnb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CNB OpenAPI的Python SDK,方便与CNB平台进行交互
|
|
5
|
+
Home-page: https://cnb.cool
|
|
6
|
+
Author: Tencent Cloud
|
|
7
|
+
Author-email: ericdduan@tencent.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Source, https://cnb.cool/cnb/sdk/python-cnb
|
|
10
|
+
Project-URL: Documentation, https://cnb.cool/docs
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
Requires-Dist: python-dotenv>=0.21.0
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: project-url
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
37
|
+
|
|
38
|
+
# Python CNB OpenAPI SDK
|
|
39
|
+
|
|
40
|
+
[](https://www.python.org/downloads/)
|
|
41
|
+
[](LICENSE)
|
|
42
|
+
<a href="https://yuanbao.tencent.com"><img src="https://img.shields.io/badge/AI-Code%20Assist-EB9FDA"></a>
|
|
43
|
+
|
|
44
|
+
CNB OpenAPI的Python SDK,方便与CNB平台进行交互。
|
|
45
|
+
> 该 sdk 由 [cnb-sdk-generator](https://cnb.cool/cnb/sdk/cnb-sdk-generator) 生成
|
|
46
|
+
|
|
47
|
+
## 功能特性
|
|
48
|
+
|
|
49
|
+
- 完整的API覆盖(用户、仓库、Issue等)
|
|
50
|
+
- 基于Pydantic的强类型模型
|
|
51
|
+
- 完善的错误处理机制
|
|
52
|
+
- 自动重试和超时控制
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
或通过PyPI安装(发布后):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install python-cnb
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 快速开始
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
def sync_api_demo():
|
|
70
|
+
# 初始化客户端
|
|
71
|
+
client = CNBClient(
|
|
72
|
+
base_url="https://api.cnb.cool",
|
|
73
|
+
api_key=os.getenv("CNB_TOKEN"), # 从环境变量获取API Key
|
|
74
|
+
max_retries=3, # 最大重试次数
|
|
75
|
+
timeout=30, # 请求超时时间(秒)
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
user_info = client.cnb.users.get_user_info()
|
|
80
|
+
print(f"用户信息: {user_info}")
|
|
81
|
+
|
|
82
|
+
except CNBAPIError as e:
|
|
83
|
+
print(f"API调用失败: {e}")
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
sync_api_demo()
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## 配置
|
|
92
|
+
|
|
93
|
+
在项目根目录创建`.env`文件:
|
|
94
|
+
|
|
95
|
+
```ini
|
|
96
|
+
API_KEY=your_cnb_api_key
|
|
97
|
+
BASE_URL=https://api.cnb.cool
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 许可证
|
|
101
|
+
|
|
102
|
+
MIT License - 详见[LICENSE](LICENSE)文件
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Python CNB OpenAPI SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
<a href="https://yuanbao.tencent.com"><img src="https://img.shields.io/badge/AI-Code%20Assist-EB9FDA"></a>
|
|
6
|
+
|
|
7
|
+
CNB OpenAPI的Python SDK,方便与CNB平台进行交互。
|
|
8
|
+
> 该 sdk 由 [cnb-sdk-generator](https://cnb.cool/cnb/sdk/cnb-sdk-generator) 生成
|
|
9
|
+
|
|
10
|
+
## 功能特性
|
|
11
|
+
|
|
12
|
+
- 完整的API覆盖(用户、仓库、Issue等)
|
|
13
|
+
- 基于Pydantic的强类型模型
|
|
14
|
+
- 完善的错误处理机制
|
|
15
|
+
- 自动重试和超时控制
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install -e .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
或通过PyPI安装(发布后):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install python-cnb
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 快速开始
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
def sync_api_demo():
|
|
33
|
+
# 初始化客户端
|
|
34
|
+
client = CNBClient(
|
|
35
|
+
base_url="https://api.cnb.cool",
|
|
36
|
+
api_key=os.getenv("CNB_TOKEN"), # 从环境变量获取API Key
|
|
37
|
+
max_retries=3, # 最大重试次数
|
|
38
|
+
timeout=30, # 请求超时时间(秒)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
user_info = client.cnb.users.get_user_info()
|
|
43
|
+
print(f"用户信息: {user_info}")
|
|
44
|
+
|
|
45
|
+
except CNBAPIError as e:
|
|
46
|
+
print(f"API调用失败: {e}")
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
sync_api_demo()
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## 配置
|
|
55
|
+
|
|
56
|
+
在项目根目录创建`.env`文件:
|
|
57
|
+
|
|
58
|
+
```ini
|
|
59
|
+
API_KEY=your_cnb_api_key
|
|
60
|
+
BASE_URL=https://api.cnb.cool
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 许可证
|
|
64
|
+
|
|
65
|
+
MIT License - 详见[LICENSE](LICENSE)文件
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Code generated by cnb.cool/cnb/sdk/cnb-sdk-generator. DO NOT EDIT.
|
|
2
|
+
# versions:
|
|
3
|
+
# cnb-sdk-generator: 1.0.2
|
|
4
|
+
# source: https://api.cnb.cool/swagger.json
|
|
5
|
+
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from .models import dto
|
|
8
|
+
class ArtifactoryService:
|
|
9
|
+
def __init__(self, client):
|
|
10
|
+
self._client = client
|
|
11
|
+
|
|
12
|
+
# 删除制品标签。 Delete the specific tag under specific package
|
|
13
|
+
def delete_package_tag(self,
|
|
14
|
+
slug: str,
|
|
15
|
+
t: str,
|
|
16
|
+
name: str,
|
|
17
|
+
tag: str,
|
|
18
|
+
):
|
|
19
|
+
u = "/%s/-/packages/%s/%s/-/tag/%s" % (slug, t, name, tag, )
|
|
20
|
+
|
|
21
|
+
data = self._client.request(
|
|
22
|
+
method="DELETE",
|
|
23
|
+
endpoint=u,
|
|
24
|
+
)
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
# 删除制品仓库。Delete the artifact repository.
|
|
28
|
+
def delete_registry(self,
|
|
29
|
+
registry: str,
|
|
30
|
+
):
|
|
31
|
+
u = "/%s" % (registry, )
|
|
32
|
+
|
|
33
|
+
data = self._client.request(
|
|
34
|
+
method="DELETE",
|
|
35
|
+
endpoint=u,
|
|
36
|
+
)
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
# 下载制品配额信息。 Download registry quota details.
|
|
40
|
+
def download_quotas_by_project_name(self,
|
|
41
|
+
slug: str,
|
|
42
|
+
t: str,
|
|
43
|
+
page: Optional[int] = None,
|
|
44
|
+
page_size: Optional[int] = None,
|
|
45
|
+
ordering: Optional[str] = None,
|
|
46
|
+
) -> list[dto.QuotaRsp]:
|
|
47
|
+
u = "/%s/-/packages/%s/-/quotas/download" % (slug, t, )
|
|
48
|
+
|
|
49
|
+
query_params = {
|
|
50
|
+
"page": page,
|
|
51
|
+
"page_size": page_size,
|
|
52
|
+
"ordering": ordering,
|
|
53
|
+
}
|
|
54
|
+
data = self._client.request(
|
|
55
|
+
method="GET",
|
|
56
|
+
endpoint=u,
|
|
57
|
+
params=query_params,
|
|
58
|
+
)
|
|
59
|
+
return [dto.QuotaRsp.safe_parse(item) for item in data]
|
|
60
|
+
|
|
61
|
+
# 获取某一制品的详细信息。 Get the package detail.
|
|
62
|
+
def get_package(self,
|
|
63
|
+
slug: str,
|
|
64
|
+
t: str,
|
|
65
|
+
name: str,
|
|
66
|
+
) -> dto.PackageDetail:
|
|
67
|
+
u = "/%s/-/packages/%s/%s" % (slug, t, name, )
|
|
68
|
+
|
|
69
|
+
data = self._client.request(
|
|
70
|
+
method="GET",
|
|
71
|
+
endpoint=u,
|
|
72
|
+
)
|
|
73
|
+
return dto.PackageDetail.safe_parse(data)
|
|
74
|
+
|
|
75
|
+
# 获取制品标签详情。 Get the specific tag under specific package.
|
|
76
|
+
def get_package_tag_detail(self,
|
|
77
|
+
slug: str,
|
|
78
|
+
t: str,
|
|
79
|
+
name: str,
|
|
80
|
+
tag: str,
|
|
81
|
+
sha256: Optional[str] = None,
|
|
82
|
+
) -> dto.TagDetail:
|
|
83
|
+
u = "/%s/-/packages/%s/%s/-/tag/%s" % (slug, t, name, tag, )
|
|
84
|
+
|
|
85
|
+
query_params = {
|
|
86
|
+
"sha256": sha256,
|
|
87
|
+
}
|
|
88
|
+
data = self._client.request(
|
|
89
|
+
method="GET",
|
|
90
|
+
endpoint=u,
|
|
91
|
+
params=query_params,
|
|
92
|
+
)
|
|
93
|
+
return dto.TagDetail.safe_parse(data)
|
|
94
|
+
|
|
95
|
+
# 查询制品配额。 Get quota of specific registry.
|
|
96
|
+
def get_quota_by_project_name(self,
|
|
97
|
+
slug: str,
|
|
98
|
+
t: str,
|
|
99
|
+
) -> dto.QuotaRsp:
|
|
100
|
+
u = "/%s/-/packages/%s/-/quota" % (slug, t, )
|
|
101
|
+
|
|
102
|
+
data = self._client.request(
|
|
103
|
+
method="GET",
|
|
104
|
+
endpoint=u,
|
|
105
|
+
)
|
|
106
|
+
return dto.QuotaRsp.safe_parse(data)
|
|
107
|
+
|
|
108
|
+
# 查询全部制品配额。 Get quotas of packages under one registry.
|
|
109
|
+
def get_quotas_by_project_name(self,
|
|
110
|
+
slug: str,
|
|
111
|
+
t: str,
|
|
112
|
+
page: Optional[int] = None,
|
|
113
|
+
page_size: Optional[int] = None,
|
|
114
|
+
ordering: Optional[str] = None,
|
|
115
|
+
) -> list[dto.QuotaRsp]:
|
|
116
|
+
u = "/%s/-/packages/%s/-/quotas" % (slug, t, )
|
|
117
|
+
|
|
118
|
+
query_params = {
|
|
119
|
+
"page": page,
|
|
120
|
+
"page_size": page_size,
|
|
121
|
+
"ordering": ordering,
|
|
122
|
+
}
|
|
123
|
+
data = self._client.request(
|
|
124
|
+
method="GET",
|
|
125
|
+
endpoint=u,
|
|
126
|
+
params=query_params,
|
|
127
|
+
)
|
|
128
|
+
return [dto.QuotaRsp.safe_parse(item) for item in data]
|
|
129
|
+
|
|
130
|
+
# 查询制品数量。 Head all packages.
|
|
131
|
+
def head_packages(self,
|
|
132
|
+
slug: str,
|
|
133
|
+
type: Optional[str] = None,
|
|
134
|
+
page: Optional[int] = None,
|
|
135
|
+
page_size: Optional[int] = None,
|
|
136
|
+
ordering: Optional[str] = None,
|
|
137
|
+
name: Optional[str] = None,
|
|
138
|
+
):
|
|
139
|
+
u = "/%s/-/packages" % (slug, )
|
|
140
|
+
|
|
141
|
+
query_params = {
|
|
142
|
+
"type": type,
|
|
143
|
+
"page": page,
|
|
144
|
+
"page_size": page_size,
|
|
145
|
+
"ordering": ordering,
|
|
146
|
+
"name": name,
|
|
147
|
+
}
|
|
148
|
+
data = self._client.request(
|
|
149
|
+
method="HEAD",
|
|
150
|
+
endpoint=u,
|
|
151
|
+
params=query_params,
|
|
152
|
+
)
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
# 查询制品标签列表。 List all tags under specific package.
|
|
156
|
+
def list_package_tags(self,
|
|
157
|
+
slug: str,
|
|
158
|
+
t: str,
|
|
159
|
+
pkgname: str,
|
|
160
|
+
page: Optional[int] = None,
|
|
161
|
+
page_size: Optional[int] = None,
|
|
162
|
+
ordering: Optional[str] = None,
|
|
163
|
+
name: Optional[str] = None,
|
|
164
|
+
) -> dto.Tag:
|
|
165
|
+
u = "/%s/-/packages/%s/%s/-/tags" % (slug, t, pkgname, )
|
|
166
|
+
|
|
167
|
+
query_params = {
|
|
168
|
+
"page": page,
|
|
169
|
+
"page_size": page_size,
|
|
170
|
+
"ordering": ordering,
|
|
171
|
+
"name": name,
|
|
172
|
+
}
|
|
173
|
+
data = self._client.request(
|
|
174
|
+
method="GET",
|
|
175
|
+
endpoint=u,
|
|
176
|
+
params=query_params,
|
|
177
|
+
)
|
|
178
|
+
return dto.Tag.safe_parse(data)
|
|
179
|
+
|
|
180
|
+
# 查询制品列表。 List all packages.
|
|
181
|
+
def list_packages(self,
|
|
182
|
+
slug: str,
|
|
183
|
+
type: Optional[str] = None,
|
|
184
|
+
page: Optional[int] = None,
|
|
185
|
+
page_size: Optional[int] = None,
|
|
186
|
+
ordering: Optional[str] = None,
|
|
187
|
+
name: Optional[str] = None,
|
|
188
|
+
) -> list[dto.Package]:
|
|
189
|
+
u = "/%s/-/packages" % (slug, )
|
|
190
|
+
|
|
191
|
+
query_params = {
|
|
192
|
+
"type": type,
|
|
193
|
+
"page": page,
|
|
194
|
+
"page_size": page_size,
|
|
195
|
+
"ordering": ordering,
|
|
196
|
+
"name": name,
|
|
197
|
+
}
|
|
198
|
+
data = self._client.request(
|
|
199
|
+
method="GET",
|
|
200
|
+
endpoint=u,
|
|
201
|
+
params=query_params,
|
|
202
|
+
)
|
|
203
|
+
return [dto.Package.safe_parse(item) for item in data]
|
|
204
|
+
|
|
205
|
+
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Code generated by cnb.cool/cnb/sdk/cnb-sdk-generator. DO NOT EDIT.
|
|
2
|
+
# versions:
|
|
3
|
+
# cnb-sdk-generator: 1.0.2
|
|
4
|
+
# source: https://api.cnb.cool/swagger.json
|
|
5
|
+
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from .models import dto
|
|
8
|
+
class AssetsService:
|
|
9
|
+
def __init__(self, client):
|
|
10
|
+
self._client = client
|
|
11
|
+
|
|
12
|
+
# 发起一个获取 commits 附件的请求,返回内容或者 302 到某个地址。Get a request to fetch a commit assets and returns the content directly or a 302 redirect to the assets URL.
|
|
13
|
+
def get_commit_assets(self,
|
|
14
|
+
repo: str,
|
|
15
|
+
fileName: str,
|
|
16
|
+
):
|
|
17
|
+
u = "/%s/-/commit-assets/download/%s" % (repo, fileName, )
|
|
18
|
+
|
|
19
|
+
data = self._client.request(
|
|
20
|
+
method="GET",
|
|
21
|
+
endpoint=u,
|
|
22
|
+
)
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
# 发起一个获取 files 的请求,返回内容或者 302 到某个地址。Initiate a request to retrieve files, returns content or 302 redirect.
|
|
26
|
+
def get_files(self,
|
|
27
|
+
repo: str,
|
|
28
|
+
userIdKey: str,
|
|
29
|
+
randomUUID: str,
|
|
30
|
+
fileName: str,
|
|
31
|
+
):
|
|
32
|
+
u = "/%s/-/files/%s/%s/%s" % (repo, userIdKey, randomUUID, fileName, )
|
|
33
|
+
|
|
34
|
+
data = self._client.request(
|
|
35
|
+
method="GET",
|
|
36
|
+
endpoint=u,
|
|
37
|
+
)
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
# 发起一个获取 imgs 的请求,返回内容或者 302 到某个地址。Initiate a request to get images, returns content or 302 redirect.
|
|
41
|
+
def get_imgs(self,
|
|
42
|
+
repo: str,
|
|
43
|
+
userIdKey: str,
|
|
44
|
+
fileName: str,
|
|
45
|
+
):
|
|
46
|
+
u = "/%s/-/imgs/%s/%s" % (repo, userIdKey, fileName, )
|
|
47
|
+
|
|
48
|
+
data = self._client.request(
|
|
49
|
+
method="GET",
|
|
50
|
+
endpoint=u,
|
|
51
|
+
)
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
# 发起一个获取 latest release 附件的请求,返回内容或者 302 到某个地址。Initiate a request to get latest release attachments, returns content or 302 redirect.
|
|
55
|
+
def get_latest_releases_asset(self,
|
|
56
|
+
repo: str,
|
|
57
|
+
fileName: str,
|
|
58
|
+
):
|
|
59
|
+
u = "/%s/-/releases/latest/download/%s" % (repo, fileName, )
|
|
60
|
+
|
|
61
|
+
data = self._client.request(
|
|
62
|
+
method="GET",
|
|
63
|
+
endpoint=u,
|
|
64
|
+
)
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
# 发起一个获取 logo 的请求,返回内容或者 302 到某个地址。Post a request to fetch a logo and returns the content directly or a 302 redirect to the logo URL.
|
|
68
|
+
def get_logos(self,
|
|
69
|
+
group: str,
|
|
70
|
+
size: str,
|
|
71
|
+
):
|
|
72
|
+
u = "/%s/-/logos/%s" % (group, size, )
|
|
73
|
+
|
|
74
|
+
data = self._client.request(
|
|
75
|
+
method="GET",
|
|
76
|
+
endpoint=u,
|
|
77
|
+
)
|
|
78
|
+
return
|
|
79
|
+
|
|
80
|
+
# 发起一个获取 release 附件的请求,返回内容或者 302 到某个地址。Initiate a request to get release attachments, returns content or 302 redirect.
|
|
81
|
+
def get_releases_asset(self,
|
|
82
|
+
repo: str,
|
|
83
|
+
fileName: str,
|
|
84
|
+
):
|
|
85
|
+
u = "/%s/-/releases/download/%s" % (repo, fileName, )
|
|
86
|
+
|
|
87
|
+
data = self._client.request(
|
|
88
|
+
method="GET",
|
|
89
|
+
endpoint=u,
|
|
90
|
+
)
|
|
91
|
+
return
|
|
92
|
+
|
|
93
|
+
# 获取指定用户的用户头像。Get the user's avatar.
|
|
94
|
+
def get_user_avatar(self,
|
|
95
|
+
username: str,
|
|
96
|
+
size: str,
|
|
97
|
+
):
|
|
98
|
+
u = "/users/%s/avatar/%s" % (username, size, )
|
|
99
|
+
|
|
100
|
+
data = self._client.request(
|
|
101
|
+
method="GET",
|
|
102
|
+
endpoint=u,
|
|
103
|
+
)
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
# 发起一个确认 files 的请求,上传的图片要调用此接口才能生效。Initiate a request to confirm files, uploaded images need to call this API to take effect.
|
|
107
|
+
def put_files(self,
|
|
108
|
+
repo: str,
|
|
109
|
+
userIdKey: str,
|
|
110
|
+
randomUUID: str,
|
|
111
|
+
fileName: str,
|
|
112
|
+
token: Optional[str] = None,
|
|
113
|
+
):
|
|
114
|
+
u = "/%s/-/files/%s/%s/%s" % (repo, userIdKey, randomUUID, fileName, )
|
|
115
|
+
|
|
116
|
+
query_params = {
|
|
117
|
+
"token": token,
|
|
118
|
+
}
|
|
119
|
+
data = self._client.request(
|
|
120
|
+
method="PUT",
|
|
121
|
+
endpoint=u,
|
|
122
|
+
params=query_params,
|
|
123
|
+
)
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
# 发起一个确认 imgs 的请求,上传的图片要调用此接口才能生效。Initiate a request to confirm images, uploaded images need to call this API to take effect.
|
|
127
|
+
def put_imgs(self,
|
|
128
|
+
repo: str,
|
|
129
|
+
userIdKey: str,
|
|
130
|
+
fileName: str,
|
|
131
|
+
token: Optional[str] = None,
|
|
132
|
+
):
|
|
133
|
+
u = "/%s/-/imgs/%s/%s" % (repo, userIdKey, fileName, )
|
|
134
|
+
|
|
135
|
+
query_params = {
|
|
136
|
+
"token": token,
|
|
137
|
+
}
|
|
138
|
+
data = self._client.request(
|
|
139
|
+
method="PUT",
|
|
140
|
+
endpoint=u,
|
|
141
|
+
params=query_params,
|
|
142
|
+
)
|
|
143
|
+
return
|
|
144
|
+
|
|
145
|
+
# 确认上传的logo。Confirms the uploaded logo.
|
|
146
|
+
def put_logos(self,
|
|
147
|
+
group: str,
|
|
148
|
+
token: Optional[str] = None,
|
|
149
|
+
):
|
|
150
|
+
u = "/%s/-/logos" % (group, )
|
|
151
|
+
|
|
152
|
+
query_params = {
|
|
153
|
+
"token": token,
|
|
154
|
+
}
|
|
155
|
+
data = self._client.request(
|
|
156
|
+
method="PUT",
|
|
157
|
+
endpoint=u,
|
|
158
|
+
params=query_params,
|
|
159
|
+
)
|
|
160
|
+
return
|
|
161
|
+
|
|
162
|
+
# 发起一个上传 files 的请求,返回上传 cos 的 url 和 form 内容。Initiate a request to upload files,returns COS upload URL and form data.
|
|
163
|
+
def upload_files(self,
|
|
164
|
+
repo: str,
|
|
165
|
+
body_params: dto.UploadRequestParams,
|
|
166
|
+
) -> dto.UploadAssetsResponse:
|
|
167
|
+
u = "/%s/-/upload/files" % (repo, )
|
|
168
|
+
|
|
169
|
+
data = self._client.request(
|
|
170
|
+
method="POST",
|
|
171
|
+
endpoint=u,
|
|
172
|
+
json=body_params.to_dict(),
|
|
173
|
+
)
|
|
174
|
+
return dto.UploadAssetsResponse.safe_parse(data)
|
|
175
|
+
|
|
176
|
+
# 发起一个上传 imgs 的请求,返回上传 cos 的 url 和 form 内容。发起一个上传 imgs 的请求,返回上传 cos 的 url 和 form 内容.
|
|
177
|
+
def upload_imgs(self,
|
|
178
|
+
repo: str,
|
|
179
|
+
body_params: dto.UploadRequestParams,
|
|
180
|
+
) -> dto.UploadAssetsResponse:
|
|
181
|
+
u = "/%s/-/upload/imgs" % (repo, )
|
|
182
|
+
|
|
183
|
+
data = self._client.request(
|
|
184
|
+
method="POST",
|
|
185
|
+
endpoint=u,
|
|
186
|
+
json=body_params.to_dict(),
|
|
187
|
+
)
|
|
188
|
+
return dto.UploadAssetsResponse.safe_parse(data)
|
|
189
|
+
|
|
190
|
+
# 发起一个上传 logo 的请求,返回上传 cos 的 url 和 form 内容。Post a request to upload a logo.
|
|
191
|
+
def upload_logos(self,
|
|
192
|
+
group: str,
|
|
193
|
+
body_params: dto.UploadRequestParams,
|
|
194
|
+
) -> dto.UploadAssetsResponse:
|
|
195
|
+
u = "/%s/-/upload/logos" % (group, )
|
|
196
|
+
|
|
197
|
+
data = self._client.request(
|
|
198
|
+
method="POST",
|
|
199
|
+
endpoint=u,
|
|
200
|
+
json=body_params.to_dict(),
|
|
201
|
+
)
|
|
202
|
+
return dto.UploadAssetsResponse.safe_parse(data)
|
|
203
|
+
|
|
204
|
+
# 发起一个上传 release 附件的请求,返回上传 cos 的 url 和 form 内容。Initiate a request to upload release attachments, returns COS upload URL and form data.
|
|
205
|
+
def upload_releases(self,
|
|
206
|
+
repo: str,
|
|
207
|
+
tagName: str,
|
|
208
|
+
body_params: dto.UploadRequestParams,
|
|
209
|
+
) -> dto.UploadAssetsResponse:
|
|
210
|
+
u = "/%s/-/upload/releases/%s" % (repo, tagName, )
|
|
211
|
+
|
|
212
|
+
data = self._client.request(
|
|
213
|
+
method="POST",
|
|
214
|
+
endpoint=u,
|
|
215
|
+
json=body_params.to_dict(),
|
|
216
|
+
)
|
|
217
|
+
return dto.UploadAssetsResponse.safe_parse(data)
|
|
218
|
+
|
|
219
|
+
|