ZSTAC-84940 Add launch command SDK bindings#4209
Conversation
Generate Java SDK action/result and ApiHelper entry for the model service launch command API.\n\nConstraint: API definitions live in premium but SDK/APIHelper output is committed in zstack.\nScope-risk: narrow\nTested: ./runMavenProfile sdk\nTested: ./runMavenProfile premium\nTested: ModelServiceCase Resolves: ZSTAC-84940 Change-Id: Ieaaee3e471e8c59052c35ff509ab4704244b9ab6
|
Warning Review limit reached
More reviews will be available in 1 minute and 7 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Warning
|
| Layer / File(s) | Summary |
|---|---|
Data Models sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsResult.java, sdk/src/main/java/org/zstack/sdk/ModelServiceInstanceLaunchCommandInventory.java |
GetModelServiceLaunchCommandsResult和ModelServiceInstanceLaunchCommandInventory类定义API响应数据结构,包含commands列表、实例标识、名称和启动命令信息的getter/setter方法。 |
SDK Class Mappings sdk/src/main/java/SourceClassMap.java |
在srcToDstMapping和dstToSrcMapping中新增ModelServiceInstanceLaunchCommandInventory的双向类名映射,支持SDK生成工具的类对应关系。 |
GetModelServiceLaunchCommandsAction Implementation sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.java |
新增Action类实现GET /ai/model-service-launch-commands API调用,包含groupUuids、instanceUuids、systemTags等查询参数,同步和异步call()方法,以及ApiResult到Result的响应转换和错误处理。 |
API Path Test Formatting testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy |
在三处System.getProperty("apipath")分支处添加空行间隔,改善块间代码可读性。 |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
小兔跳跃新命令,✨
查询模型服务群,
API路径已铺平,
数据映射双向成,
启动之旅从此始~ 🚀
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | 拉取请求标题清晰准确地反映了主要变更内容:添加启动命令的SDK绑定,与变更集完全相关。 |
| Description check | ✅ Passed | 拉取请求描述详细说明了变更的摘要、根本原因、具体修改内容及验证过程,与变更集完全相关且信息充分。 |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
sync/ye.zou/fix/ZSTAC-84940-feature-5.5.28-aios@@2
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.java (1)
5-5: ⚡ Quick win避免使用通配符导入
使用通配符导入
import org.zstack.sdk.*;会降低代码可读性,并可能引入不必要的类。建议显式导入所需的类。🔧 建议的修复
import java.util.HashMap; import java.util.Map; -import org.zstack.sdk.*; +import org.zstack.sdk.AbstractAction; +import org.zstack.sdk.ApiException; +import org.zstack.sdk.ApiResult; +import org.zstack.sdk.Completion; +import org.zstack.sdk.ErrorCode; +import org.zstack.sdk.InternalCompletion; +import org.zstack.sdk.Param; +import org.zstack.sdk.RestInfo; +import org.zstack.sdk.ZSClient;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.java` at line 5, The file uses a wildcard import "import org.zstack.sdk.*;" which should be replaced with explicit imports to improve readability; update the import list in GetModelServiceLaunchCommandsAction.java by removing the wildcard and adding explicit import statements for each type referenced in this file (e.g., the action class types, result/response types, session or API client types used here) so only the needed classes from org.zstack.sdk are imported.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.java`:
- Line 29: The fields declared as raw types—groupUuids and instanceUuids in
class GetModelServiceLaunchCommandsAction—should be changed from java.util.List
to java.util.List<String> to restore compile-time type safety; update both field
declarations (groupUuids and instanceUuids) to use the generic parameter String
and adjust any usages/calls that assume raw List to avoid unchecked warnings.
- Line 35: The fields systemTags and userTags in class
GetModelServiceLaunchCommandsAction use raw java.util.List types making the code
unsafe; change their declarations to use generics (java.util.List<String>) and
update any related getters, setters, constructors, or usages in this class (and
any code referencing these fields) to expect List<String> instead of raw List so
compilation and type-safety are preserved; ensure imports remain correct or use
fully-qualified java.util.List<String> where needed.
In `@sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsResult.java`:
- Line 6: 字段 commands 在类 GetModelServiceLaunchCommandsResult 中使用了原始类型
List;请将其改为带泛型的 List<ModelServiceInstanceLaunchCommandInventory>,并相应地更新对应的 getter
和 setter 的签名(getCommands()/setCommands(...))为使用该泛型类型,同时添加或确认已存在对
org.zstack.sdk.ModelServiceInstanceLaunchCommandInventory 的导入以保证编译通过并维持类型安全。
In
`@sdk/src/main/java/org/zstack/sdk/ModelServiceInstanceLaunchCommandInventory.java`:
- Line 3: 删除不必要的同包导入:移除文件中多余的 import
org.zstack.sdk.ModelServiceLaunchCommandInventory; 陈述问题并在类
ModelServiceInstanceLaunchCommandInventory 所在文件中直接引用
ModelServiceLaunchCommandInventory 而不做显式导入即可,确保没有其他未使用的导入残留并运行编译以验证。
---
Nitpick comments:
In `@sdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.java`:
- Line 5: The file uses a wildcard import "import org.zstack.sdk.*;" which
should be replaced with explicit imports to improve readability; update the
import list in GetModelServiceLaunchCommandsAction.java by removing the wildcard
and adding explicit import statements for each type referenced in this file
(e.g., the action class types, result/response types, session or API client
types used here) so only the needed classes from org.zstack.sdk are imported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 845e27fd-537a-4823-bcaf-cca8abb0feb7
📒 Files selected for processing (5)
sdk/src/main/java/SourceClassMap.javasdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsAction.javasdk/src/main/java/org/zstack/sdk/GetModelServiceLaunchCommandsResult.javasdk/src/main/java/org/zstack/sdk/ModelServiceInstanceLaunchCommandInventory.javatestlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
Type the generated launch command SDK fields and remove the redundant same-package import reported during MR review. Resolves: ZSTAC-84940 Change-Id: I59d7efaddfca3166f57c2b091adbdb2069f58fd7
Commit the output produced by ./runMavenProfile sdk so update_sdk verification stays clean. Resolves: ZSTAC-84940 Change-Id: I27eadd7fc19c37b70b00888a20b0fe1e805eb863
Summary
Add generated SDK and ApiHelper bindings for the model service launch command query API.
Root Cause
The API implementation lives in premium, while Java SDK and ApiHelper generated outputs are committed in zstack.
Change
GetModelServiceLaunchCommandsActionand result class.ModelServiceInstanceLaunchCommandInventorySDK model.SourceClassMapandApiHelper.groovy.Verification
./runMavenProfile sdkin privileged PR docker: PASS, total 01:28./runMavenProfile premiumin privileged PR docker with mounted zstack+premium: PASS, total 15:01ModelServiceCasewith-Djacoco.skip=true: PASS, 1 test, 0 failures/errors/skipped, total 12:02Risk
Narrow. Generated client/helper bindings only.
Resolves: ZSTAC-84940
sync from gitlab !10166