data-ops-cli 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
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.
- {data_ops_cli-0.2.3.dist-info → data_ops_cli-0.2.4.dist-info}/METADATA +1 -1
- {data_ops_cli-0.2.3.dist-info → data_ops_cli-0.2.4.dist-info}/RECORD +32 -28
- dataops_cli/__init__.py +1 -1
- dataops_cli/cli/api.py +227 -0
- dataops_cli/cli/auth.py +8 -5
- dataops_cli/cli/data_table.py +5 -6
- dataops_cli/cli/dataset.py +5 -5
- dataops_cli/cli/datasource.py +5 -6
- dataops_cli/cli/dict_.py +5 -5
- dataops_cli/cli/factory.py +2 -0
- dataops_cli/cli/metrics.py +5 -5
- dataops_cli/cli/report.py +5 -5
- dataops_cli/cli/table.py +103 -31
- dataops_cli/cli/utils.py +12 -0
- dataops_cli/cli/widget.py +423 -19
- dataops_cli/cli/workflow.py +5 -5
- dataops_cli/constants.py +0 -1
- dataops_cli/runner/utils/dbConn_sync.py +16 -7
- dataops_cli/schems/__init__.py +4 -2
- dataops_cli/schems/api.py +37 -0
- dataops_cli/schems/meta.py +6 -1
- dataops_cli/schems/table.py +14 -14
- dataops_cli/schems/widget.py +107 -11
- dataops_cli/sdk/__init__.py +7 -0
- dataops_cli/sdk/api.py +28 -0
- dataops_cli/sdk/datasource.py +7 -0
- dataops_cli/sdk/meta.py +37 -28
- dataops_cli/sdk/table.py +128 -0
- dataops_cli/sdk/widget.py +99 -0
- {data_ops_cli-0.2.3.dist-info → data_ops_cli-0.2.4.dist-info}/WHEEL +0 -0
- {data_ops_cli-0.2.3.dist-info → data_ops_cli-0.2.4.dist-info}/entry_points.txt +0 -0
- {data_ops_cli-0.2.3.dist-info → data_ops_cli-0.2.4.dist-info}/top_level.txt +0 -0
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
dataops_cli/__init__.py,sha256=
|
|
2
|
-
dataops_cli/constants.py,sha256=
|
|
1
|
+
dataops_cli/__init__.py,sha256=SBl2EPFW-ltPvQ7vbVWItyAsz3aKYIpjO7vcfr84GkU,22
|
|
2
|
+
dataops_cli/constants.py,sha256=qRRNMjH9_6fwL7e9fRZHpHnJG1ZqRHUEPPzPpfqGSKc,197
|
|
3
3
|
dataops_cli/exceptions.py,sha256=GnNqDlMfgjMiL0Kp-H0KZMDJdRAckG6kd3V-NJiugFg,575
|
|
4
4
|
dataops_cli/session.py,sha256=TnI-4MAMQYBxsTu5yvaxwSqGoBEytV2xakvVIyADudU,6632
|
|
5
5
|
dataops_cli/utils.py,sha256=-7iBbYjp9JM5LhuCkNhYoNITa26YJxyhd_oTYzPjERU,3740
|
|
6
6
|
dataops_cli/cli/__init__.py,sha256=TvJw3xrE81YSwUrauHaJwQsRNf-YAlxLnadce1KYo4c,67
|
|
7
|
-
dataops_cli/cli/
|
|
8
|
-
dataops_cli/cli/
|
|
9
|
-
dataops_cli/cli/
|
|
10
|
-
dataops_cli/cli/
|
|
11
|
-
dataops_cli/cli/
|
|
12
|
-
dataops_cli/cli/
|
|
13
|
-
dataops_cli/cli/
|
|
7
|
+
dataops_cli/cli/api.py,sha256=EuTDeTgwF9Kx9XtdJ8t4ZSA_oFEK710F-AUWF74Y0_I,6979
|
|
8
|
+
dataops_cli/cli/auth.py,sha256=zYizqzIDSnLIvOk-Sev1sxyVPqNffTUfhh4XiSw9eaI,6369
|
|
9
|
+
dataops_cli/cli/data_table.py,sha256=buwO0PLk6xY-LeA0QCvAzRz1Y0xSQg5qsix1-CGFtE8,9345
|
|
10
|
+
dataops_cli/cli/dataset.py,sha256=zWV1GzQRlVmaeovMe3cmKukK0NxxVyWwK--uowA8VD8,3241
|
|
11
|
+
dataops_cli/cli/datasource.py,sha256=1V74KjgV8feIx4xHeysVPBd3fL3_VHyeH98q0_IejQA,7196
|
|
12
|
+
dataops_cli/cli/dict_.py,sha256=FEoZvStXvZhMLknuFbxAACqI4B0-xwQID3vz_tIF7aY,3054
|
|
13
|
+
dataops_cli/cli/factory.py,sha256=-iVbKLm5egSWOzXa9KraXhccnGaKhDjHMD7hq1BFRFA,1707
|
|
14
|
+
dataops_cli/cli/metrics.py,sha256=U8EfbpxIgZ8oZYf8mTdz9Ke-ZA1t7RqaaMJ7aonYWsA,6160
|
|
14
15
|
dataops_cli/cli/ref.py,sha256=jfc5EhkXrhqUwu4IuftEjUepPB3d6SK4ZDhrh40YGOE,4765
|
|
15
|
-
dataops_cli/cli/report.py,sha256
|
|
16
|
-
dataops_cli/cli/table.py,sha256=
|
|
17
|
-
dataops_cli/cli/utils.py,sha256=
|
|
18
|
-
dataops_cli/cli/widget.py,sha256=
|
|
19
|
-
dataops_cli/cli/workflow.py,sha256=
|
|
16
|
+
dataops_cli/cli/report.py,sha256=Vrhz_U7qGiSmefZsq_rDarxrv6e4BG_R3yjudFsYuDE,2403
|
|
17
|
+
dataops_cli/cli/table.py,sha256=kctKGadjD5Dnrkp8fLbwpfcDSthJ7ojiHoj-FMdt3II,13405
|
|
18
|
+
dataops_cli/cli/utils.py,sha256=ZpCGbLj4eIBfdYiI0-XJWRnY9PSaX7xrjD2e_HWA4O8,884
|
|
19
|
+
dataops_cli/cli/widget.py,sha256=9vELuNpGCGVgyacjPK7b_evDdgOZ3wIiJboEqz5NwfI,15367
|
|
20
|
+
dataops_cli/cli/workflow.py,sha256=hfsDUtRbU4f-9sD0VH-Brx3xWbNNI8x8rv8-UAi9zPs,4756
|
|
20
21
|
dataops_cli/runner/__init__.py,sha256=BursdHKoU_4Bq-BhrYxNCJ88SpUajeMzVrnLMpbC4fc,767
|
|
21
22
|
dataops_cli/runner/schemas/nacos/__init__.py,sha256=yXsULXK8G5IiZz2c26yrVhtvflbDLwgTkajm74YAA10,146
|
|
22
23
|
dataops_cli/runner/schemas/nacos/config.py,sha256=pHrwJRoDGQNuqMVoQnkmNF0ENqUqcmUvp-j3Q_YgTx0,1326
|
|
@@ -31,34 +32,37 @@ dataops_cli/runner/schemas/nacos/service.py,sha256=C-27WmWW-ziZuplMTp2-xcIIPONVm
|
|
|
31
32
|
dataops_cli/runner/utils/__init__.py,sha256=C0e_iiM80fScn_FGL4-HIRwmsHADiyN5TQ08a75FgQk,880
|
|
32
33
|
dataops_cli/runner/utils/common.py,sha256=fz7uUjVRluZUUUaIhw2b9OXvs5k9M_W0l4TH6oxGilg,6282
|
|
33
34
|
dataops_cli/runner/utils/dbConn_base.py,sha256=3reXPJ9uAcOVhl3sRNe4MPplYpKfG5DTfW0ETaqXeEo,8239
|
|
34
|
-
dataops_cli/runner/utils/dbConn_sync.py,sha256=
|
|
35
|
+
dataops_cli/runner/utils/dbConn_sync.py,sha256=qi010MbZvtPmSeDJe1tlbklWXVaqiCEN_7IhnBdKIPA,13293
|
|
35
36
|
dataops_cli/runner/utils/duckdb_manager.py,sha256=xIREgkx6hcAbt6cYSTEHfGPGu7QgZsCwQrU4u2Vb1ng,6902
|
|
36
37
|
dataops_cli/runner/utils/log.py,sha256=EwctSAohPIP1wo2FtUTjv5kswyoGHK70-2CFlyQ9yN4,1438
|
|
37
38
|
dataops_cli/runner/utils/nacos.py,sha256=HSJyjswRk1ohzzUEjn4yRDtWKPjgsU_yYoS1nh5TWss,2994
|
|
38
39
|
dataops_cli/runner/utils/neo4j_sync.py,sha256=cbpb4K5QUHcD1DuJg7_KeoBi8N1DLwru2sbiDMq779M,6603
|
|
39
|
-
dataops_cli/schems/__init__.py,sha256=
|
|
40
|
+
dataops_cli/schems/__init__.py,sha256=Kln_wipkevaaFp24lYcrdwogok7Jsnz3YEO60WK68kk,837
|
|
41
|
+
dataops_cli/schems/api.py,sha256=x522Vf2leZnn8-bfllGoldy59zrS4a-c06B0uGQhfhw,1477
|
|
40
42
|
dataops_cli/schems/data_table.py,sha256=tLCOcaTMIoM5KySHYE97YSqBly95cjlbmyZcUZL1Lv0,16516
|
|
41
43
|
dataops_cli/schems/datasource.py,sha256=gSFoQm5ZNhn3PxcrM24WLpvJcT_QHOhNp_2J3cbIT6A,854
|
|
42
44
|
dataops_cli/schems/dict_.py,sha256=Y0ebyXYCw4vBhBgHyPXCz_4yVALAxMkQQlxSQsjJNs0,394
|
|
43
45
|
dataops_cli/schems/enums.py,sha256=9gB08DPwAr2gthzuxew0pI91e8byaVH34I03eu4kDhc,2111
|
|
44
46
|
dataops_cli/schems/group.py,sha256=TvH0nsrGz1DpftrLAPpHqQuhMNgu0e5gu_Og3PiVnBc,1306
|
|
45
|
-
dataops_cli/schems/meta.py,sha256=
|
|
47
|
+
dataops_cli/schems/meta.py,sha256=2CVkxZyo04fhPagdt_QziCxwyIT1IICo04NNy8IvnsY,6500
|
|
46
48
|
dataops_cli/schems/query.py,sha256=AWH0P51lkBQEKhotIOoqJaOEIEoaWaiT_r7hSXlzK2Q,6455
|
|
47
49
|
dataops_cli/schems/report.py,sha256=Eklh1gMaRoPDvgrWZIBrLkQXhB0KuuAteJUzOzZngb8,493
|
|
48
|
-
dataops_cli/schems/table.py,sha256=
|
|
50
|
+
dataops_cli/schems/table.py,sha256=qJuxgMD7AGiNoDi6QrlIihuHJDAVx637VDdb2y9TtN4,2527
|
|
49
51
|
dataops_cli/schems/user.py,sha256=mAPgLCCKeoC7qvOj6TOSC2xI3OrL7P5eNOGy4R3RVyw,2522
|
|
50
|
-
dataops_cli/schems/widget.py,sha256=
|
|
52
|
+
dataops_cli/schems/widget.py,sha256=0LMXf5JitH4bLy1ciyTh337QRxoekh4tsUyoCgFMxHU,25420
|
|
51
53
|
dataops_cli/schems/workflow.py,sha256=opRkEwYXntTO-BCOLcZJK2joA32qELpdnN6pI2LS_2Y,1805
|
|
52
|
-
dataops_cli/sdk/__init__.py,sha256=
|
|
54
|
+
dataops_cli/sdk/__init__.py,sha256=My6AHo7SSRGLDTLBHJMHBudcTabZuRKmqWJNlPOmld0,1362
|
|
55
|
+
dataops_cli/sdk/api.py,sha256=dq5toBJQ26m40GB3dygU8gcZCt9p8i-fpUs82o-4v6s,787
|
|
53
56
|
dataops_cli/sdk/auth.py,sha256=xA3x99lv5x1vgcy66pGvdh8Dw2OQc82Npku9iNOcXXs,3729
|
|
54
57
|
dataops_cli/sdk/data_table.py,sha256=7focA6HBv-4nwbIrBdZ4-S7ull-EjP3MuG4tYWghK6U,6827
|
|
55
58
|
dataops_cli/sdk/dataset.py,sha256=2qb52OVGhU6XAxeVjJoTjdazLNAmT9L9yxgIlphd7-4,1268
|
|
56
|
-
dataops_cli/sdk/datasource.py,sha256=
|
|
59
|
+
dataops_cli/sdk/datasource.py,sha256=EWnCx3enBScNYsdKuez18B4Eg0yYXoHa10Uc9DP5R6A,2371
|
|
57
60
|
dataops_cli/sdk/dict_.py,sha256=RLsvlrC-ARYXPudLczGOySmFp-z3p8yjw6QujL59Qc0,1790
|
|
58
|
-
dataops_cli/sdk/meta.py,sha256=
|
|
61
|
+
dataops_cli/sdk/meta.py,sha256=JooSMEsCL3okXN1B6GWweUZ5XAULi-l1X7J0PpRqw74,17289
|
|
59
62
|
dataops_cli/sdk/ref.py,sha256=BPttMiqaW7z1nuCvgY0nV6d-u1O1i_EbEJ7ZrL0KhFY,1925
|
|
60
63
|
dataops_cli/sdk/report.py,sha256=uBmfgPCzqRMJQk8yS3kqSMLgOKijKEDRNOWamhjC6mw,376
|
|
61
|
-
dataops_cli/sdk/table.py,sha256=
|
|
64
|
+
dataops_cli/sdk/table.py,sha256=0zwgeTtSVwTV9KHab_ARIV0ao2Q9NLdvodMe6u3iHpA,9699
|
|
65
|
+
dataops_cli/sdk/widget.py,sha256=q4T7rEAANIgnJINNVweY99IBjhUeICz8fNCcje0jMbA,2828
|
|
62
66
|
dataops_cli/sdk/workflow.py,sha256=go39E4Cc96bEuNW0pGeDvZZwonkKQ5njMaFTwLW-3jE,472
|
|
63
67
|
dataops_cli/tiptap/__init__.py,sha256=UaHc1Q0T6OtmN02WNxTY1tp1-Iw8wzZjIyZE6rlMBgQ,612
|
|
64
68
|
dataops_cli/tiptap/builder.py,sha256=w8lzbCcRo-AOFRvOoN3b_JV4hNLch_iSPbcYIcSqelk,2245
|
|
@@ -68,8 +72,8 @@ dataops_cli/tiptap/parse_utils.py,sha256=iJ4_gean-tkPXks4UShXuyPAkUwwFh41WL6cS7G
|
|
|
68
72
|
dataops_cli/tiptap/render_utils.py,sha256=f5CDNLm0Y3uPXD0oPEjq4cKw1hDvWviY3IVlfS05vzE,21021
|
|
69
73
|
dataops_cli/tiptap/renderers.py,sha256=qHAeYZeJf1Wip0svKtmy-28uFSeoTELzh3iE8bAQwaw,1235
|
|
70
74
|
dataops_cli/tiptap/tool.py,sha256=7Uxoq-Kv_3XzU5ZW0k16wzwz79nhQf8D6qq7ygxERLw,27902
|
|
71
|
-
data_ops_cli-0.2.
|
|
72
|
-
data_ops_cli-0.2.
|
|
73
|
-
data_ops_cli-0.2.
|
|
74
|
-
data_ops_cli-0.2.
|
|
75
|
-
data_ops_cli-0.2.
|
|
75
|
+
data_ops_cli-0.2.4.dist-info/METADATA,sha256=zOQE2Vq0i_SkMYNktLwS0vgfq7WXSC7Y46vZKUPcxT4,503
|
|
76
|
+
data_ops_cli-0.2.4.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
77
|
+
data_ops_cli-0.2.4.dist-info/entry_points.txt,sha256=vc_2b5byVdLofaQ2ppuPM484AcaZnGsaHdcMKmtcSkU,53
|
|
78
|
+
data_ops_cli-0.2.4.dist-info/top_level.txt,sha256=KFHplpKxwE9_wWypzVLESa4eLkOBsk-iUD_Qbld2IcY,12
|
|
79
|
+
data_ops_cli-0.2.4.dist-info/RECORD,,
|
dataops_cli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.4"
|
dataops_cli/cli/api.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""API 接口管理模块.
|
|
2
|
+
|
|
3
|
+
提供 API 接口的列表查询和详情功能。
|
|
4
|
+
|
|
5
|
+
- 服务层函数 (service_*):纯 Python 接口,返回原始数据
|
|
6
|
+
- CLI 命令:基于服务层的薄包装,负责格式化输出
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import shutil
|
|
10
|
+
from typing import Annotated
|
|
11
|
+
|
|
12
|
+
import typer
|
|
13
|
+
|
|
14
|
+
from dataops_cli.exceptions import DataOpsError
|
|
15
|
+
from dataops_cli.schems import MetaType
|
|
16
|
+
from dataops_cli.sdk.api import service_get_api_by_code
|
|
17
|
+
from dataops_cli.sdk.meta import release_list_list
|
|
18
|
+
from dataops_cli.utils import filter_nodes_by_pattern
|
|
19
|
+
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
# 常量
|
|
22
|
+
# ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
_STATUS_MAP: dict[str, str] = {
|
|
25
|
+
"dev": "开发中",
|
|
26
|
+
"test": "测试中",
|
|
27
|
+
"prod": "已发布",
|
|
28
|
+
"deprecated": "将弃用",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_SCOPE_MAP: dict[str, str] = {
|
|
32
|
+
"public": "公开接口",
|
|
33
|
+
"internal": "内部接口",
|
|
34
|
+
"external": "外部接口",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
# CLI 命令
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
api_typer = typer.Typer(
|
|
42
|
+
name="api",
|
|
43
|
+
help="Manage APIs",
|
|
44
|
+
no_args_is_help=True,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _first_line(text: str) -> str:
|
|
49
|
+
"""取文本的第一行."""
|
|
50
|
+
return text.split("\n")[0]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@api_typer.command("list", rich_help_panel="API 查询")
|
|
54
|
+
def list_apis(
|
|
55
|
+
query: Annotated[
|
|
56
|
+
str | None, typer.Option("-q", "--query", help="按名称/标题/备注正则过滤")
|
|
57
|
+
] = None,
|
|
58
|
+
) -> None:
|
|
59
|
+
"""列出所有 API 接口.
|
|
60
|
+
|
|
61
|
+
从元数据服务获取 API 接口列表,支持通过正则表达式按名称、标题或备注进行过滤。
|
|
62
|
+
|
|
63
|
+
示例:
|
|
64
|
+
列出所有 API 接口
|
|
65
|
+
>>> data-ops-cli api list
|
|
66
|
+
|
|
67
|
+
按名称/标题/备注过滤
|
|
68
|
+
>>> data-ops-cli api list --query ".*用户.*"
|
|
69
|
+
>>> data-ops-cli api list -q "用户"
|
|
70
|
+
"""
|
|
71
|
+
try:
|
|
72
|
+
group_nodes = release_list_list(MetaType.API)
|
|
73
|
+
except DataOpsError as e:
|
|
74
|
+
typer.echo(f"错误: {e.message}")
|
|
75
|
+
raise typer.Exit(code=1) from None
|
|
76
|
+
|
|
77
|
+
if query:
|
|
78
|
+
group_nodes = filter_nodes_by_pattern(group_nodes, query)
|
|
79
|
+
|
|
80
|
+
if not group_nodes:
|
|
81
|
+
print("(无结果)")
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
print("code title remark")
|
|
85
|
+
|
|
86
|
+
for node in group_nodes:
|
|
87
|
+
code = node.CODE
|
|
88
|
+
title = node.TITLE
|
|
89
|
+
remark_raw = node.REMARK or ""
|
|
90
|
+
remark = _first_line(remark_raw.strip())
|
|
91
|
+
print(code, title, remark)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@api_typer.command("detail", rich_help_panel="API 查询", no_args_is_help=True)
|
|
95
|
+
def get_api_detail(
|
|
96
|
+
code: Annotated[str, typer.Argument(help="API 接口编码")],
|
|
97
|
+
simplify: Annotated[
|
|
98
|
+
bool,
|
|
99
|
+
typer.Option("-s", "--simplify", help="仅显示基本信息,不展示请求/响应参数"),
|
|
100
|
+
] = False,
|
|
101
|
+
) -> None:
|
|
102
|
+
"""获取 API 接口详情.
|
|
103
|
+
|
|
104
|
+
根据 API 接口编码获取详细信息,包括请求方法、路径、状态、请求参数和响应参数。
|
|
105
|
+
|
|
106
|
+
示例:
|
|
107
|
+
获取 API 接口完整信息
|
|
108
|
+
>>> data-ops-cli api detail user_login
|
|
109
|
+
|
|
110
|
+
仅显示基本信息
|
|
111
|
+
>>> data-ops-cli api detail user_login --simplify
|
|
112
|
+
>>> data-ops-cli api detail user_login -s
|
|
113
|
+
"""
|
|
114
|
+
try:
|
|
115
|
+
meta = service_get_api_by_code(code)
|
|
116
|
+
except DataOpsError as e:
|
|
117
|
+
typer.echo(f"错误: {e.message}")
|
|
118
|
+
raise typer.Exit(code=1) from None
|
|
119
|
+
|
|
120
|
+
d = meta.data
|
|
121
|
+
method = d.method
|
|
122
|
+
status_label = _STATUS_MAP.get(d.status, d.status)
|
|
123
|
+
scope_label = _SCOPE_MAP.get(d.scope, d.scope)
|
|
124
|
+
|
|
125
|
+
# 基本信息
|
|
126
|
+
print(f"方法: {method}")
|
|
127
|
+
print(f"路径: {d.endpoint}")
|
|
128
|
+
print(f"状态: {status_label}")
|
|
129
|
+
print(f"范围: {scope_label}")
|
|
130
|
+
if d.charger:
|
|
131
|
+
print(f"负责人: {d.charger}")
|
|
132
|
+
if d.env_code:
|
|
133
|
+
print(f"API 环境: {d.env_code}")
|
|
134
|
+
if d.description:
|
|
135
|
+
print(f"\n说明:\n{d.description}")
|
|
136
|
+
|
|
137
|
+
if simplify:
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
# 请求参数
|
|
141
|
+
rp = d.requestParam
|
|
142
|
+
print("\n--- 请求参数 ---")
|
|
143
|
+
|
|
144
|
+
# 认证
|
|
145
|
+
auth = rp.get("authParam", {})
|
|
146
|
+
if auth:
|
|
147
|
+
auth_type = auth.get("type", "none")
|
|
148
|
+
print(f" 认证: {auth_type}")
|
|
149
|
+
|
|
150
|
+
# Headers
|
|
151
|
+
headers = rp.get("headers", [])
|
|
152
|
+
if headers:
|
|
153
|
+
print(f" 请求头 ({len(headers)}):")
|
|
154
|
+
for h in headers:
|
|
155
|
+
required = " *" if h.get("required") else ""
|
|
156
|
+
print(f" - {h.get('name', '?')}: {h.get('title', '')}{required}")
|
|
157
|
+
|
|
158
|
+
# Path params
|
|
159
|
+
path_params = rp.get("pathParams", [])
|
|
160
|
+
if path_params:
|
|
161
|
+
print(f" 路径参数 ({len(path_params)}):")
|
|
162
|
+
for p in path_params:
|
|
163
|
+
required = " *" if p.get("required") else ""
|
|
164
|
+
print(
|
|
165
|
+
f" - {p.get('name', '?')}: {p.get('title', '')} ({p.get('type', '?')}){required}"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
# Query params
|
|
169
|
+
query_params = rp.get("queryParams", [])
|
|
170
|
+
if query_params:
|
|
171
|
+
print(f" Query 参数 ({len(query_params)}):")
|
|
172
|
+
for q in query_params:
|
|
173
|
+
required = " *" if q.get("required") else ""
|
|
174
|
+
print(
|
|
175
|
+
f" - {q.get('name', '?')}: {q.get('title', '')} ({q.get('type', '?')}){required}"
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Body
|
|
179
|
+
body = rp.get("bodyParams", {})
|
|
180
|
+
if body:
|
|
181
|
+
mine_type = body.get("mineType", "none")
|
|
182
|
+
if mine_type != "none":
|
|
183
|
+
structure = body.get("structure", [])
|
|
184
|
+
print(f" 请求体: {mine_type}")
|
|
185
|
+
if structure:
|
|
186
|
+
_print_params_tree(structure, indent=4)
|
|
187
|
+
|
|
188
|
+
# Cookies
|
|
189
|
+
cookies = rp.get("cookies", [])
|
|
190
|
+
if cookies:
|
|
191
|
+
print(f" Cookie ({len(cookies)}):")
|
|
192
|
+
for c in cookies:
|
|
193
|
+
print(f" - {c.get('name', '?')}: {c.get('title', '')}")
|
|
194
|
+
|
|
195
|
+
# 响应参数
|
|
196
|
+
response_params = d.responseParams
|
|
197
|
+
if response_params:
|
|
198
|
+
print("\n--- 响应参数 ---")
|
|
199
|
+
for rp_item in response_params:
|
|
200
|
+
status_code = rp_item.get("status_code", "?")
|
|
201
|
+
title = rp_item.get("title", "")
|
|
202
|
+
mine_type = rp_item.get("mineType", "")
|
|
203
|
+
structure = rp_item.get("structure", [])
|
|
204
|
+
print(f" [{status_code}] {title} ({mine_type})")
|
|
205
|
+
if structure:
|
|
206
|
+
_print_params_tree(structure, indent=4)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _print_params_tree(params: list[dict], indent: int = 0, prefix: str = "") -> None:
|
|
210
|
+
"""递归打印参数树结构."""
|
|
211
|
+
for p in params:
|
|
212
|
+
ptype = p.get("type", "?")
|
|
213
|
+
name = p.get("name", "?")
|
|
214
|
+
title = p.get("title", "")
|
|
215
|
+
required = " *" if p.get("required") else ""
|
|
216
|
+
desc = p.get("description", "")
|
|
217
|
+
line = f"{' ' * indent}- {prefix}{name}: {title} ({ptype}){required}"
|
|
218
|
+
if desc:
|
|
219
|
+
line += f" # {desc}"
|
|
220
|
+
print(line)
|
|
221
|
+
if ptype in ("object", "array"):
|
|
222
|
+
children = p.get("children", [])
|
|
223
|
+
if children:
|
|
224
|
+
if ptype == "array":
|
|
225
|
+
_print_params_tree(children, indent + 2)
|
|
226
|
+
else:
|
|
227
|
+
_print_params_tree(children, indent + 2)
|
dataops_cli/cli/auth.py
CHANGED
|
@@ -12,6 +12,7 @@ import typer
|
|
|
12
12
|
from rich.console import Console
|
|
13
13
|
from rich.table import Table
|
|
14
14
|
|
|
15
|
+
from dataops_cli.cli.utils import print_list
|
|
15
16
|
from dataops_cli.constants import USER_INFO_FILE
|
|
16
17
|
from dataops_cli.exceptions import AuthenticationError
|
|
17
18
|
from dataops_cli.schems import UserInfo
|
|
@@ -135,11 +136,13 @@ def application_list(query: Annotated[str | None, typer.Argument(help="关键字
|
|
|
135
136
|
typer.echo(f"错误: {e}")
|
|
136
137
|
raise typer.Exit(code=1) from None
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
print_list(
|
|
140
|
+
["code", "title", "remark"],
|
|
141
|
+
[
|
|
142
|
+
[application.CODE, application.LABEL_CN, application.REMARK]
|
|
143
|
+
for application in applications
|
|
144
|
+
],
|
|
145
|
+
)
|
|
143
146
|
|
|
144
147
|
|
|
145
148
|
@application_typer.command("set")
|
dataops_cli/cli/data_table.py
CHANGED
|
@@ -11,7 +11,7 @@ import typer
|
|
|
11
11
|
from rich.console import Console
|
|
12
12
|
from rich.table import Table
|
|
13
13
|
|
|
14
|
-
from dataops_cli.cli.utils import render_table
|
|
14
|
+
from dataops_cli.cli.utils import print_list, render_table
|
|
15
15
|
from dataops_cli.exceptions import DataOpsError
|
|
16
16
|
from dataops_cli.schems import MetaType, PageParam, SqlQueryParam
|
|
17
17
|
from dataops_cli.sdk import (
|
|
@@ -63,11 +63,10 @@ def list_datatable(
|
|
|
63
63
|
if query:
|
|
64
64
|
group_nodes = filter_nodes_by_pattern(group_nodes, query, include_digest=True)
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.print(table)
|
|
66
|
+
print_list(
|
|
67
|
+
["code", "title", "remark"],
|
|
68
|
+
[[column.CODE, column.TITLE, column.REMARK] for column in group_nodes],
|
|
69
|
+
)
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
@data_table_typer.command("detail", no_args_is_help=True)
|
dataops_cli/cli/dataset.py
CHANGED
|
@@ -4,6 +4,7 @@ import typer
|
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
from rich.table import Table
|
|
6
6
|
|
|
7
|
+
from dataops_cli.cli.utils import print_list
|
|
7
8
|
from dataops_cli.exceptions import DataOpsError
|
|
8
9
|
from dataops_cli.sdk import service_get_dataset_detail_by_code, service_list_datasets
|
|
9
10
|
from dataops_cli.utils import filter_nodes_by_pattern
|
|
@@ -35,11 +36,10 @@ def list_dataset(
|
|
|
35
36
|
if query:
|
|
36
37
|
group_nodes = filter_nodes_by_pattern(group_nodes, query, include_digest=True)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
console.print(table)
|
|
39
|
+
print_list(
|
|
40
|
+
["code", "name", "alias", "remark"],
|
|
41
|
+
[[column.CODE, column.NAME, column.TITLE, column.REMARK] for column in group_nodes],
|
|
42
|
+
)
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@dataset_typer.command("detail", no_args_is_help=True)
|
dataops_cli/cli/datasource.py
CHANGED
|
@@ -19,19 +19,18 @@ from dataops_cli.schems import (
|
|
|
19
19
|
DataDataSource,
|
|
20
20
|
InnerMetaType,
|
|
21
21
|
MetaCreate,
|
|
22
|
-
MetaUpdate,
|
|
23
22
|
)
|
|
24
23
|
from dataops_cli.schems.enums import DataSourceType
|
|
25
|
-
from dataops_cli.sdk.datasource import
|
|
24
|
+
from dataops_cli.sdk.datasource import (
|
|
25
|
+
get_application_datasource_config,
|
|
26
|
+
service_get_datasource_by_name,
|
|
27
|
+
)
|
|
26
28
|
from dataops_cli.sdk.meta import (
|
|
27
29
|
release_list_create,
|
|
28
30
|
release_list_get_by_name,
|
|
29
31
|
release_list_list,
|
|
30
32
|
release_list_update,
|
|
31
33
|
)
|
|
32
|
-
from dataops_cli.sdk.table import (
|
|
33
|
-
service_get_table_data_by_name,
|
|
34
|
-
)
|
|
35
34
|
from dataops_cli.session import get_application
|
|
36
35
|
from dataops_cli.utils import filter_nodes_by_pattern
|
|
37
36
|
|
|
@@ -113,7 +112,7 @@ def get_datasource_detail(
|
|
|
113
112
|
Args:
|
|
114
113
|
name: 数据源名称
|
|
115
114
|
"""
|
|
116
|
-
meta =
|
|
115
|
+
meta = service_get_datasource_by_name(name)
|
|
117
116
|
table = Table("field", "value", show_header=False)
|
|
118
117
|
table.add_row("name", meta.name)
|
|
119
118
|
table.add_row("title", meta.title)
|
dataops_cli/cli/dict_.py
CHANGED
|
@@ -4,6 +4,7 @@ import typer
|
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
from rich.table import Table
|
|
6
6
|
|
|
7
|
+
from dataops_cli.cli.utils import print_list
|
|
7
8
|
from dataops_cli.exceptions import DataOpsError
|
|
8
9
|
from dataops_cli.sdk.dict_ import (
|
|
9
10
|
service_get_dict_detail_by_code,
|
|
@@ -47,11 +48,10 @@ def list_dict(
|
|
|
47
48
|
if query:
|
|
48
49
|
group_nodes = filter_nodes_by_pattern(group_nodes, query)
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.print(table)
|
|
51
|
+
print_list(
|
|
52
|
+
["code", "name", "alias"],
|
|
53
|
+
[[column.CODE, column.NAME, column.TITLE] for column in group_nodes],
|
|
54
|
+
)
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
@dict_typer.command("detail", no_args_is_help=True)
|
dataops_cli/cli/factory.py
CHANGED
|
@@ -25,6 +25,7 @@ def main(
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def create_app():
|
|
28
|
+
from dataops_cli.cli.api import api_typer
|
|
28
29
|
from dataops_cli.cli.auth import auth_typer
|
|
29
30
|
from dataops_cli.cli.data_table import data_table_typer
|
|
30
31
|
from dataops_cli.cli.dataset import dataset_typer
|
|
@@ -44,6 +45,7 @@ def create_app():
|
|
|
44
45
|
short_help=True,
|
|
45
46
|
)
|
|
46
47
|
app.add_typer(auth_typer)
|
|
48
|
+
app.add_typer(api_typer)
|
|
47
49
|
app.add_typer(datasource_typer)
|
|
48
50
|
app.add_typer(dataset_typer)
|
|
49
51
|
app.add_typer(table_typer)
|
dataops_cli/cli/metrics.py
CHANGED
|
@@ -12,6 +12,7 @@ import typer
|
|
|
12
12
|
from rich.console import Console
|
|
13
13
|
from rich.table import Table
|
|
14
14
|
|
|
15
|
+
from dataops_cli.cli.utils import print_list
|
|
15
16
|
from dataops_cli.schems.enums import MetaType
|
|
16
17
|
from dataops_cli.schems.query import SqlQueryParam
|
|
17
18
|
from dataops_cli.sdk.meta import (
|
|
@@ -56,11 +57,10 @@ def list_metrics(
|
|
|
56
57
|
|
|
57
58
|
if query:
|
|
58
59
|
group_nodes = filter_nodes_by_pattern(group_nodes, query)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
console.print(table)
|
|
60
|
+
print_list(
|
|
61
|
+
["code", "title", "subType"],
|
|
62
|
+
[[column.CODE, column.TITLE, column.SUB_TYPE or "atomic"] for column in group_nodes],
|
|
63
|
+
)
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
@metrics_typer.command("detail", no_args_is_help=True)
|
dataops_cli/cli/report.py
CHANGED
|
@@ -12,6 +12,7 @@ import typer
|
|
|
12
12
|
from rich.console import Console
|
|
13
13
|
from rich.table import Table
|
|
14
14
|
|
|
15
|
+
from dataops_cli.cli.utils import print_list
|
|
15
16
|
from dataops_cli.exceptions import DataOpsError
|
|
16
17
|
from dataops_cli.schems import MetaType
|
|
17
18
|
from dataops_cli.sdk.meta import (
|
|
@@ -51,11 +52,10 @@ def list_reports(
|
|
|
51
52
|
if query:
|
|
52
53
|
group_nodes = filter_nodes_by_pattern(group_nodes, query)
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.print(table)
|
|
55
|
+
print_list(
|
|
56
|
+
["code", "title", "subType"],
|
|
57
|
+
[[column.CODE, column.TITLE, column.SUB_TYPE or "doc"] for column in group_nodes],
|
|
58
|
+
)
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
@report_typer.command("detail", rich_help_panel="报告查询")
|