-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathcreate_application_apis.py
More file actions
44 lines (34 loc) · 1.18 KB
/
create_application_apis.py
File metadata and controls
44 lines (34 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
"""批量创建 openlark-application API"""
import os
BASE = "crates/openlark-application/src/application/application/v1"
# 简化的 API 定义 - 创建基本的骨架
endpoints = [
("app", "create"),
("app", "delete"),
("app", "get"),
("app", "list"),
("app", "patch"),
("app", "update"),
("app/visibility", "patch"),
("app/visibility", "get"),
("app_version", "create"),
("app_version", "delete"),
("app_version", "get"),
("app_version", "list"),
("app_version", "patch"),
]
template = '''pub struct {name}Request;
pub struct {name}Response;
'''
for resource, action in endpoints:
dir_path = os.path.join(BASE, resource)
file_path = os.path.join(dir_path, f"{action}.rs")
os.makedirs(dir_path, exist_ok=True)
api_name = "".join([p.capitalize() for p in resource.replace("/", "_").split("_")]) + action.capitalize()
with open(file_path, 'w') as f:
f.write(f"//! {resource} {action}\n\n")
f.write(f"pub struct {api_name}Request;\n")
f.write(f"pub struct {api_name}Response;\n")
print(f"✅ {file_path}")
print(f"\n✅ openlark-application API 骨架已创建")