compshare-cli 0.2.1__tar.gz → 0.3.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.
Files changed (52) hide show
  1. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/PKG-INFO +66 -11
  2. compshare_cli-0.3.0/README.md +210 -0
  3. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/pyproject.toml +3 -1
  4. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/__init__.py +1 -1
  5. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/actions.py +4 -0
  6. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/api.py +19 -13
  7. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/cli.py +87 -14
  8. compshare_cli-0.3.0/src/compshare_cli/commands/ask.py +31 -0
  9. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/common.py +8 -9
  10. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/doctor.py +2 -2
  11. compshare_cli-0.3.0/src/compshare_cli/commands/feedback.py +20 -0
  12. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/image.py +50 -37
  13. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/instance.py +269 -117
  14. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/storage.py +23 -18
  15. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/team.py +16 -16
  16. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/config.py +5 -5
  17. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/i18n.py +86 -12
  18. compshare_cli-0.3.0/src/compshare_cli/insights.py +146 -0
  19. compshare_cli-0.3.0/src/compshare_cli/location.py +85 -0
  20. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/output.py +57 -11
  21. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/parsing.py +13 -0
  22. compshare_cli-0.3.0/src/compshare_cli/qa.py +51 -0
  23. compshare_cli-0.3.0/src/compshare_cli/runtime.py +20 -0
  24. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/sdk.py +2 -2
  25. compshare_cli-0.3.0/src/compshare_cli/ssh.py +250 -0
  26. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/PKG-INFO +66 -11
  27. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/SOURCES.txt +9 -1
  28. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/entry_points.txt +1 -0
  29. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/requires.txt +3 -0
  30. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_actions.py +9 -2
  31. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_api.py +19 -0
  32. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_cli.py +625 -27
  33. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_config.py +3 -14
  34. compshare_cli-0.3.0/tests/test_feedback.py +154 -0
  35. compshare_cli-0.3.0/tests/test_location.py +103 -0
  36. compshare_cli-0.3.0/tests/test_output.py +61 -0
  37. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_parsing.py +4 -0
  38. compshare_cli-0.3.0/tests/test_qa.py +121 -0
  39. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/tests/test_sdk.py +6 -0
  40. compshare_cli-0.3.0/tests/test_ssh.py +209 -0
  41. compshare_cli-0.2.1/README.md +0 -156
  42. compshare_cli-0.2.1/src/compshare_cli/location.py +0 -91
  43. compshare_cli-0.2.1/src/compshare_cli/runtime.py +0 -34
  44. compshare_cli-0.2.1/tests/test_location.py +0 -39
  45. compshare_cli-0.2.1/tests/test_output.py +0 -28
  46. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/LICENSE +0 -0
  47. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/setup.cfg +0 -0
  48. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/__main__.py +0 -0
  49. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/commands/__init__.py +0 -0
  50. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli/errors.py +0 -0
  51. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/dependency_links.txt +0 -0
  52. {compshare_cli-0.2.1 → compshare_cli-0.3.0}/src/compshare_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compshare-cli
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: Command-line client for CompShare GPU compute
5
5
  Author: CompShare
6
6
  License-Expression: Apache-2.0
@@ -12,6 +12,7 @@ Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: click<9,>=8.1
15
+ Requires-Dist: pexpect<5,>=4.9; platform_system != "Windows"
15
16
  Requires-Dist: rich<15,>=13
16
17
  Requires-Dist: typer<1,>=0.12
17
18
  Requires-Dist: ucloud-sdk-python3<0.12,>=0.11.103
@@ -30,14 +31,16 @@ Dynamic: license-file
30
31
  - 支持批量生命周期操作、等待状态和跨地域查询
31
32
  - 支持社区/自定义镜像、云盘、团队额度与账单
32
33
  - 默认中文帮助,可切换英文;所有命令支持 JSON 输出
34
+ - 可通过 `compshare ask` 查询产品使用和计费知识
35
+ - 可通过 `compshare feedback` 反馈 CLI 问题和建议
33
36
  - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
34
37
 
35
- 当前版本:`0.2.1`,要求 Python 3.9 或更高版本。
38
+ 当前版本:`0.3.0`,要求 Python 3.9 或更高版本。
36
39
 
37
40
  ## 安装
38
41
 
39
42
  ```bash
40
- python -m pip install "git+https://github.com/BennielAllan/compshare-cli.git"
43
+ pip install compshare-cli
41
44
  compshare -h
42
45
  ```
43
46
 
@@ -82,8 +85,9 @@ export COMPSHARE_PRIVATE_KEY='...'
82
85
 
83
86
  ```bash
84
87
  # 查规格、库存和实例
85
- compshare instance search
86
- compshare instance search --gpu 4090 --image IMAGE_ID --available
88
+ compshare instance search --region cn-sh2 --zone cn-sh2-02
89
+ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
90
+ --gpu 4090 --image IMAGE_ID --available
87
91
  compshare instance list --all
88
92
 
89
93
  # 交互式创建
@@ -96,12 +100,25 @@ compshare instance wait INSTANCE_1 INSTANCE_2 --state Running
96
100
 
97
101
  # SSH
98
102
  compshare instance ssh INSTANCE_ID
103
+ # 默认自动填写 API 返回的密码;需要手动输入时可关闭
104
+ compshare instance ssh INSTANCE_ID --no-auto-password
105
+ # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
106
+ compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
107
+ compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
108
+ # 上传本地文件或目录,目录会自动递归复制
109
+ compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
110
+ compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
111
+
112
+ # 产品问答
113
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
99
114
  ```
100
115
 
101
116
  自动化创建示例:
102
117
 
103
118
  ```bash
104
119
  compshare instance create \
120
+ --region cn-sh2 \
121
+ --zone cn-sh2-02 \
105
122
  --gpu 4090 \
106
123
  --count 1 \
107
124
  --cpu 16 \
@@ -123,8 +140,33 @@ compshare image 平台、自定义、社区及共享镜像
123
140
  compshare storage 云盘和 US3 挂载
124
141
  compshare team 团队、邀请、成员额度、账单和审计
125
142
  compshare doctor 配置、鉴权、网络与 SSH 环境诊断
143
+ compshare ask 产品使用和计费问答
144
+ compshare feedback 反馈 CLI 问题或建议
126
145
  ```
127
146
 
147
+ ## 产品问答
148
+
149
+ ```bash
150
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
151
+ compshare --json ask "如何创建自定义镜像?"
152
+ ```
153
+
154
+ 普通输出显示答案和引用资料标题;`--json` 返回完整的答案、引用、请求 ID 和检索元数据。
155
+ 命令只向内置问答服务发送 `question` 字段,不会附带 API 凭证、配置文件或其他命令上下文。
156
+
157
+ ## 反馈
158
+
159
+ ```bash
160
+ compshare feedback bug "创建实例时发生错误"
161
+ compshare feedback suggest "希望支持保存默认创建规格"
162
+ ```
163
+
164
+ 反馈会直接发送到内置的 CompShare Insights 服务地址。开发环境可使用
165
+ `COMPSHARE_INSIGHTS_URL=http://127.0.0.1:18080` 覆盖服务地址。
166
+
167
+ CLI 会异步统计指令使用情况,且仅发送指令名称、CLI 版本、操作系统和发生时间;不会发送
168
+ 命令参数、凭证、资源 ID 或命令输出。
169
+
128
170
  查看完整命令和参数:
129
171
 
130
172
  ```bash
@@ -135,23 +177,30 @@ compshare instance create -h
135
177
 
136
178
  ## 脚本调用
137
179
 
138
- `--json` 和 `--profile` 是全局选项,必须放在子命令前:
180
+ `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
139
181
 
140
182
  ```bash
141
183
  compshare --json instance list --status Running --all
142
- compshare --profile production image list --source community
184
+ compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
185
+ compshare --json --show-sensitive instance show uhost-xxxxxxxx
143
186
  ```
144
187
 
145
188
  JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
146
- `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。
189
+ `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
190
+ 密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
147
191
 
148
192
  Region 和 Zone 是资源参数,放在对应子命令后:
149
193
 
150
194
  ```bash
151
195
  compshare instance list --region cn-sh2
152
- compshare instance create --zone cn-sh2-02
196
+ compshare instance create --region cn-sh2 --zone cn-sh2-02
197
+ compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
153
198
  ```
154
199
 
200
+ CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
201
+ 执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
202
+ 字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
203
+
155
204
  ## 语言
156
205
 
157
206
  ```bash
@@ -166,7 +215,12 @@ compshare lang # 查看当前语言
166
215
 
167
216
  - 配置目录和文件分别使用 `0700`、`0600` 权限。
168
217
  - API 私钥不会出现在命令输出中。
169
- - `instance create` `instance ssh` 会显示 API 返回的实例登录密码,请妥善保管终端输出。
218
+ - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
219
+ - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
220
+ - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
221
+ - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
222
+ - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
223
+ - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
170
224
  - 删除、关机、重启、重装和改配等操作默认要求确认。
171
225
 
172
226
  ## 开发校验
@@ -177,4 +231,5 @@ ruff format --check .
177
231
  pytest
178
232
  ```
179
233
 
180
- 公开 API 覆盖范围和版本变化见 [CHANGELOG.md](CHANGELOG.md)
234
+ 公开 API 覆盖范围和版本变化见 [CHANGELOG.md](CHANGELOG.md),维护者发布流程见
235
+ [RELEASING.md](RELEASING.md)。
@@ -0,0 +1,210 @@
1
+ # CompShare CLI
2
+
3
+ 在终端管理优云智算 GPU 实例、镜像、云盘、US3 挂载和团队资源。
4
+
5
+ - 交互式创建实例,实时查询规格、库存和价格
6
+ - 支持批量生命周期操作、等待状态和跨地域查询
7
+ - 支持社区/自定义镜像、云盘、团队额度与账单
8
+ - 默认中文帮助,可切换英文;所有命令支持 JSON 输出
9
+ - 可通过 `compshare ask` 查询产品使用和计费知识
10
+ - 可通过 `compshare feedback` 反馈 CLI 问题和建议
11
+ - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
12
+
13
+ 当前版本:`0.3.0`,要求 Python 3.9 或更高版本。
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pip install compshare-cli
19
+ compshare -h
20
+ ```
21
+
22
+ 本地开发:
23
+
24
+ ```bash
25
+ git clone https://github.com/BennielAllan/compshare-cli.git
26
+ cd compshare-cli
27
+ python -m venv .venv
28
+ source .venv/bin/activate
29
+ python -m pip install -e '.[dev]'
30
+ ```
31
+
32
+ Windows 激活虚拟环境时使用:
33
+
34
+ ```powershell
35
+ .\.venv\Scripts\Activate.ps1
36
+ ```
37
+
38
+ ## 配置
39
+
40
+ ```bash
41
+ compshare config --name default
42
+ ```
43
+
44
+ 凭证保存在 `~/.config/compshare/config.json`,支持多个配置:
45
+
46
+ ```bash
47
+ compshare config list
48
+ compshare config use production
49
+ compshare --profile production instance list
50
+ ```
51
+
52
+ 也可以使用环境变量:
53
+
54
+ ```bash
55
+ export COMPSHARE_PUBLIC_KEY='...'
56
+ export COMPSHARE_PRIVATE_KEY='...'
57
+ ```
58
+
59
+ ## 快速开始
60
+
61
+ ```bash
62
+ # 查规格、库存和实例
63
+ compshare instance search --region cn-sh2 --zone cn-sh2-02
64
+ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
65
+ --gpu 4090 --image IMAGE_ID --available
66
+ compshare instance list --all
67
+
68
+ # 交互式创建
69
+ compshare instance create
70
+
71
+ # 批量操作与等待
72
+ compshare instance stop INSTANCE_1 INSTANCE_2
73
+ compshare instance start INSTANCE_1 INSTANCE_2
74
+ compshare instance wait INSTANCE_1 INSTANCE_2 --state Running
75
+
76
+ # SSH
77
+ compshare instance ssh INSTANCE_ID
78
+ # 默认自动填写 API 返回的密码;需要手动输入时可关闭
79
+ compshare instance ssh INSTANCE_ID --no-auto-password
80
+ # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
81
+ compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
82
+ compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
83
+ # 上传本地文件或目录,目录会自动递归复制
84
+ compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
85
+ compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
86
+
87
+ # 产品问答
88
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
89
+ ```
90
+
91
+ 自动化创建示例:
92
+
93
+ ```bash
94
+ compshare instance create \
95
+ --region cn-sh2 \
96
+ --zone cn-sh2-02 \
97
+ --gpu 4090 \
98
+ --count 1 \
99
+ --cpu 16 \
100
+ --memory 64GiB \
101
+ --image IMAGE_ID \
102
+ --disk 100GiB \
103
+ --charge Postpay \
104
+ --max-price 20 \
105
+ --yes
106
+ ```
107
+
108
+ 使用 `--dry-run` 只检查库存、价格和请求,不创建资源。
109
+
110
+ ## 功能入口
111
+
112
+ ```text
113
+ compshare instance GPU 实例、规格、库存、价格和生命周期
114
+ compshare image 平台、自定义、社区及共享镜像
115
+ compshare storage 云盘和 US3 挂载
116
+ compshare team 团队、邀请、成员额度、账单和审计
117
+ compshare doctor 配置、鉴权、网络与 SSH 环境诊断
118
+ compshare ask 产品使用和计费问答
119
+ compshare feedback 反馈 CLI 问题或建议
120
+ ```
121
+
122
+ ## 产品问答
123
+
124
+ ```bash
125
+ compshare ask "按量实例关机以后,云硬盘还收费吗?"
126
+ compshare --json ask "如何创建自定义镜像?"
127
+ ```
128
+
129
+ 普通输出显示答案和引用资料标题;`--json` 返回完整的答案、引用、请求 ID 和检索元数据。
130
+ 命令只向内置问答服务发送 `question` 字段,不会附带 API 凭证、配置文件或其他命令上下文。
131
+
132
+ ## 反馈
133
+
134
+ ```bash
135
+ compshare feedback bug "创建实例时发生错误"
136
+ compshare feedback suggest "希望支持保存默认创建规格"
137
+ ```
138
+
139
+ 反馈会直接发送到内置的 CompShare Insights 服务地址。开发环境可使用
140
+ `COMPSHARE_INSIGHTS_URL=http://127.0.0.1:18080` 覆盖服务地址。
141
+
142
+ CLI 会异步统计指令使用情况,且仅发送指令名称、CLI 版本、操作系统和发生时间;不会发送
143
+ 命令参数、凭证、资源 ID 或命令输出。
144
+
145
+ 查看完整命令和参数:
146
+
147
+ ```bash
148
+ compshare -h
149
+ compshare instance -h
150
+ compshare instance create -h
151
+ ```
152
+
153
+ ## 脚本调用
154
+
155
+ `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
156
+
157
+ ```bash
158
+ compshare --json instance list --status Running --all
159
+ compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
160
+ compshare --json --show-sensitive instance show uhost-xxxxxxxx
161
+ ```
162
+
163
+ JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
164
+ `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
165
+ 密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
166
+
167
+ Region 和 Zone 是资源参数,放在对应子命令后:
168
+
169
+ ```bash
170
+ compshare instance list --region cn-sh2
171
+ compshare instance create --region cn-sh2 --zone cn-sh2-02
172
+ compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
173
+ ```
174
+
175
+ CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
176
+ 执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
177
+ 字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
178
+
179
+ ## 语言
180
+
181
+ ```bash
182
+ compshare lang en
183
+ compshare lang zh
184
+ compshare lang # 查看当前语言
185
+ ```
186
+
187
+ 也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
188
+
189
+ ## 安全说明
190
+
191
+ - 配置目录和文件分别使用 `0700`、`0600` 权限。
192
+ - API 私钥不会出现在命令输出中。
193
+ - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
194
+ - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
195
+ - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
196
+ - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
197
+ - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
198
+ - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
199
+ - 删除、关机、重启、重装和改配等操作默认要求确认。
200
+
201
+ ## 开发校验
202
+
203
+ ```bash
204
+ ruff check .
205
+ ruff format --check .
206
+ pytest
207
+ ```
208
+
209
+ 公开 API 覆盖范围和版本变化见 [CHANGELOG.md](CHANGELOG.md),维护者发布流程见
210
+ [RELEASING.md](RELEASING.md)。
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compshare-cli"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "Command-line client for CompShare GPU compute"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -15,6 +15,7 @@ authors = [
15
15
  ]
16
16
  dependencies = [
17
17
  "click>=8.1,<9",
18
+ "pexpect>=4.9,<5; platform_system != 'Windows'",
18
19
  "rich>=13,<15",
19
20
  "typer>=0.12,<1",
20
21
  "ucloud-sdk-python3>=0.11.103,<0.12",
@@ -36,6 +37,7 @@ dev = [
36
37
 
37
38
  [project.scripts]
38
39
  compshare = "compshare_cli.cli:main"
40
+ compshare-ssh-askpass = "compshare_cli.ssh:askpass"
39
41
 
40
42
  [tool.setuptools.packages.find]
41
43
  where = ["src"]
@@ -1,3 +1,3 @@
1
1
  """CompShare command-line client."""
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.3.0"
@@ -89,5 +89,9 @@ TEAM_ACTIONS = frozenset(
89
89
 
90
90
  PUBLIC_ACTIONS = INSTANCE_ACTIONS | IMAGE_ACTIONS | STORAGE_ACTIONS | TEAM_ACTIONS
91
91
 
92
+ # Public API actions intentionally exposed as CLI placeholders until their
93
+ # production request contract is ready.
94
+ COMING_SOON_ACTIONS = frozenset({"GetCompShareInstanceMonitor"})
95
+
92
96
  # Documented publicly but unavailable in the production API (RetCode 161).
93
97
  UNAVAILABLE_ACTIONS = frozenset({"DescribeFavoriteImages"})
@@ -13,6 +13,12 @@ from compshare_cli.runtime import Runtime
13
13
  from compshare_cli.sdk import CompShareSDK
14
14
 
15
15
 
16
+ def _sdk(runtime: Runtime, params: Dict[str, Any]) -> CompShareSDK:
17
+ raw_region = params.get("Region")
18
+ region = str(raw_region) if raw_region is not None else None
19
+ return CompShareSDK(runtime.profile, region)
20
+
21
+
16
22
  def invoke(
17
23
  runtime: Runtime,
18
24
  action: str,
@@ -23,13 +29,13 @@ def invoke(
23
29
  columns: Optional[Sequence[Tuple[str, str]]] = None,
24
30
  success: Optional[str] = None,
25
31
  ) -> Dict[str, Any]:
26
- renderer = Renderer(runtime.json_output)
32
+ renderer = Renderer(runtime.json_output, runtime.show_sensitive)
27
33
  retries = 3 if action == "DeleteCompshareDisk" else 0
28
34
  attempt = 0
29
35
  try:
30
36
  while True:
31
37
  try:
32
- response = CompShareSDK(runtime.profile, runtime.region).invoke(action, params)
38
+ response = _sdk(runtime, params).invoke(action, params)
33
39
  break
34
40
  except ucloud_exc.RetCodeException as error:
35
41
  if error.code == 8434 and attempt < retries:
@@ -80,13 +86,13 @@ def invoke(
80
86
  def call(runtime: Runtime, action: str, params: Dict[str, Any]) -> Dict[str, Any]:
81
87
  """Invoke without rendering, for commands that combine multiple API calls."""
82
88
  try:
83
- return CompShareSDK(runtime.profile, runtime.region).invoke(action, params)
89
+ return _sdk(runtime, params).invoke(action, params)
84
90
  except CLIError as error:
85
- Renderer(runtime.json_output).error(str(error))
91
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
86
92
  raise typer.Exit(1) from error
87
93
  except ucloud_exc.RetCodeException as error:
88
94
  hint = error_hint(error.action or action, error.code)
89
- Renderer(runtime.json_output).error(
95
+ Renderer(runtime.json_output, runtime.show_sensitive).error(
90
96
  _with_hint(error.message or str(error), hint),
91
97
  details={
92
98
  "action": error.action,
@@ -97,10 +103,10 @@ def call(runtime: Runtime, action: str, params: Dict[str, Any]) -> Dict[str, Any
97
103
  )
98
104
  raise typer.Exit(1) from error
99
105
  except ucloud_exc.UCloudException as error:
100
- Renderer(runtime.json_output).error(str(error))
106
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
101
107
  raise typer.Exit(1) from error
102
108
  except Exception as error:
103
- Renderer(runtime.json_output).error(str(error))
109
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
104
110
  raise typer.Exit(1) from error
105
111
 
106
112
 
@@ -111,7 +117,7 @@ def call_captured(
111
117
  ) -> Tuple[Optional[Dict[str, Any]], Optional[Dict[str, Any]]]:
112
118
  """Invoke without rendering and return a structured error for batch operations."""
113
119
  try:
114
- return CompShareSDK(runtime.profile, runtime.region).invoke(action, params), None
120
+ return _sdk(runtime, params).invoke(action, params), None
115
121
  except CLIError as error:
116
122
  return None, {"message": str(error), "action": action}
117
123
  except ucloud_exc.RetCodeException as error:
@@ -187,13 +193,13 @@ def download_file(
187
193
  ) -> Tuple[bytes, Dict[str, str]]:
188
194
  """Download a non-JSON API response while preserving normal CLI error handling."""
189
195
  try:
190
- return CompShareSDK(runtime.profile, runtime.region).download(action, params)
196
+ return _sdk(runtime, params).download(action, params)
191
197
  except CLIError as error:
192
- Renderer(runtime.json_output).error(str(error))
198
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
193
199
  raise typer.Exit(1) from error
194
200
  except ucloud_exc.RetCodeException as error:
195
201
  hint = error_hint(error.action or action, error.code)
196
- Renderer(runtime.json_output).error(
202
+ Renderer(runtime.json_output, runtime.show_sensitive).error(
197
203
  _with_hint(error.message or str(error), hint),
198
204
  details={
199
205
  "action": error.action or action,
@@ -204,10 +210,10 @@ def download_file(
204
210
  )
205
211
  raise typer.Exit(1) from error
206
212
  except ucloud_exc.UCloudException as error:
207
- Renderer(runtime.json_output).error(str(error))
213
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
208
214
  raise typer.Exit(1) from error
209
215
  except Exception as error:
210
- Renderer(runtime.json_output).error(str(error))
216
+ Renderer(runtime.json_output, runtime.show_sensitive).error(str(error))
211
217
  raise typer.Exit(1) from error
212
218
 
213
219