Files
larksuite-cli/shortcuts/apps/db_common.go

43 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package apps
import (
"fmt"
"strings"
"github.com/larksuite/cli/internal/validate"
)
// URL helpers for the db CLI commands.
// appTablesPath 返回 app db 表列表 URL复用存量「获取数据表列表」接口
func appTablesPath(appID string) string {
return fmt.Sprintf("%s/apps/%s/tables", apiBasePath, validate.EncodePathSegment(appID))
}
// appTablePath 返回单个 app db 表详情 URL复用存量「获取数据表详细信息」接口
func appTablePath(appID, table string) string {
return appTablesPath(appID) + "/" + validate.EncodePathSegment(table)
}
// appSQLPath 返回 app db SQL 执行 URL复用存量「执行 SQL」接口
func appSQLPath(appID string) string {
return fmt.Sprintf("%s/apps/%s/sql_commands", apiBasePath, validate.EncodePathSegment(appID))
}
// appDbEnvCreatePath 返回 app db 环境创建 URL服务端接口名仍为 db_dev_init
func appDbEnvCreatePath(appID string) string {
return fmt.Sprintf("%s/apps/%s/db_dev_init", apiBasePath, validate.EncodePathSegment(appID))
}
// requireAppID trims --app-id and rejects blank, returning a uniform validation error.
func requireAppID(raw string) (string, error) {
id := strings.TrimSpace(raw)
if id == "" {
return "", appsValidationParamError("--app-id", "--app-id is required")
}
return id, nil
}