devops-mcp-server-extension 1.0.0
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.
- package/LICENSE +218 -0
- package/README.md +527 -0
- package/README.zh-cn.md +503 -0
- package/dist/common/errors.js +77 -0
- package/dist/common/modularTemplates.js +483 -0
- package/dist/common/pipelineTemplates.js +19 -0
- package/dist/common/toolsetManager.js +123 -0
- package/dist/common/toolsets.js +23 -0
- package/dist/common/types.js +60 -0
- package/dist/common/utils.js +381 -0
- package/dist/common/version.js +1 -0
- package/dist/index.js +225 -0
- package/dist/operations/appstack/appOrchestrations.js +260 -0
- package/dist/operations/appstack/appTags.js +168 -0
- package/dist/operations/appstack/appTemplates.js +72 -0
- package/dist/operations/appstack/applications.js +171 -0
- package/dist/operations/appstack/changeOrders.js +320 -0
- package/dist/operations/appstack/changeRequests.js +288 -0
- package/dist/operations/appstack/deploymentResources.js +286 -0
- package/dist/operations/appstack/globalVars.js +221 -0
- package/dist/operations/appstack/releaseWorkflows.js +695 -0
- package/dist/operations/appstack/variableGroups.js +245 -0
- package/dist/operations/codeup/branches.js +157 -0
- package/dist/operations/codeup/changeRequestComments.js +140 -0
- package/dist/operations/codeup/changeRequests.js +230 -0
- package/dist/operations/codeup/commits.js +121 -0
- package/dist/operations/codeup/compare.js +30 -0
- package/dist/operations/codeup/files.js +249 -0
- package/dist/operations/codeup/repositories.js +71 -0
- package/dist/operations/codeup/types.js +414 -0
- package/dist/operations/flow/hostGroup.js +52 -0
- package/dist/operations/flow/pipeline.js +609 -0
- package/dist/operations/flow/pipelineJob.js +126 -0
- package/dist/operations/flow/resourceMember.js +137 -0
- package/dist/operations/flow/serviceConnection.js +27 -0
- package/dist/operations/flow/tag.js +191 -0
- package/dist/operations/flow/types.js +523 -0
- package/dist/operations/flow/vmDeployOrder.js +171 -0
- package/dist/operations/organization/members.js +106 -0
- package/dist/operations/organization/organization.js +110 -0
- package/dist/operations/organization/types.js +111 -0
- package/dist/operations/packages/artifacts.js +71 -0
- package/dist/operations/packages/repositories.js +39 -0
- package/dist/operations/packages/types.js +56 -0
- package/dist/operations/projex/effort.js +122 -0
- package/dist/operations/projex/project.js +243 -0
- package/dist/operations/projex/sprint.js +103 -0
- package/dist/operations/projex/types.js +618 -0
- package/dist/operations/projex/workitem.js +826 -0
- package/dist/operations/testhub/testcases.js +240 -0
- package/dist/operations/testhub/testplans.js +128 -0
- package/dist/tool-handlers/appstack-app-release-workflows.js +103 -0
- package/dist/tool-handlers/appstack-change-orders.js +55 -0
- package/dist/tool-handlers/appstack-change-requests.js +49 -0
- package/dist/tool-handlers/appstack-deployment-resources.js +31 -0
- package/dist/tool-handlers/appstack-global-vars.js +37 -0
- package/dist/tool-handlers/appstack-orchestrations.js +49 -0
- package/dist/tool-handlers/appstack-release-workflows.js +37 -0
- package/dist/tool-handlers/appstack-tags.js +37 -0
- package/dist/tool-handlers/appstack-templates.js +19 -0
- package/dist/tool-handlers/appstack-variable-groups.js +55 -0
- package/dist/tool-handlers/appstack.js +37 -0
- package/dist/tool-handlers/base.js +25 -0
- package/dist/tool-handlers/code-management.js +150 -0
- package/dist/tool-handlers/commit.js +31 -0
- package/dist/tool-handlers/effort.js +103 -0
- package/dist/tool-handlers/index.js +119 -0
- package/dist/tool-handlers/organization.js +72 -0
- package/dist/tool-handlers/packages.js +32 -0
- package/dist/tool-handlers/pipeline.js +289 -0
- package/dist/tool-handlers/project-management.js +201 -0
- package/dist/tool-handlers/resourceMember.js +43 -0
- package/dist/tool-handlers/service-connections.js +16 -0
- package/dist/tool-handlers/tag.js +64 -0
- package/dist/tool-handlers/test-management.js +74 -0
- package/dist/tool-handlers/vmDeployOrder.js +50 -0
- package/dist/tool-registry/appstack-app-release-workflows.js +80 -0
- package/dist/tool-registry/appstack-change-orders.js +40 -0
- package/dist/tool-registry/appstack-change-requests.js +35 -0
- package/dist/tool-registry/appstack-deployment-resources.js +20 -0
- package/dist/tool-registry/appstack-global-vars.js +25 -0
- package/dist/tool-registry/appstack-orchestrations.js +35 -0
- package/dist/tool-registry/appstack-release-workflows.js +25 -0
- package/dist/tool-registry/appstack-tags.js +25 -0
- package/dist/tool-registry/appstack-templates.js +10 -0
- package/dist/tool-registry/appstack-variable-groups.js +40 -0
- package/dist/tool-registry/appstack.js +25 -0
- package/dist/tool-registry/base.js +19 -0
- package/dist/tool-registry/code-management.js +109 -0
- package/dist/tool-registry/commit.js +20 -0
- package/dist/tool-registry/effort.js +39 -0
- package/dist/tool-registry/index.js +7 -0
- package/dist/tool-registry/organization.js +65 -0
- package/dist/tool-registry/packages.js +21 -0
- package/dist/tool-registry/pipeline.js +190 -0
- package/dist/tool-registry/project-management.js +143 -0
- package/dist/tool-registry/resourceMember.js +29 -0
- package/dist/tool-registry/service-connections.js +10 -0
- package/dist/tool-registry/tag.js +44 -0
- package/dist/tool-registry/test-management.js +59 -0
- package/dist/tool-registry/vmDeployOrder.js +34 -0
- package/package.json +52 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { yunxiaoRequest, buildUrl, isRegionEdition } from '../../common/utils.js';
|
|
3
|
+
import { resolveOrganizationId } from '../organization/organization.js';
|
|
4
|
+
// Define the referenced schemas based on their definitions in appstack.swagger.json
|
|
5
|
+
const DeployMachineLogSchema = z.object({
|
|
6
|
+
aliyunRegion: z.string().optional(),
|
|
7
|
+
deployBeginTime: z.number().optional(),
|
|
8
|
+
deployEndTime: z.number().optional(),
|
|
9
|
+
deployLog: z.string().optional(),
|
|
10
|
+
deployLogPath: z.string().optional(),
|
|
11
|
+
}).describe("主机部署日志");
|
|
12
|
+
const ResourceClaimSchema = z.object({
|
|
13
|
+
instanceName: z.string().describe("所引用的资源示例唯一名"),
|
|
14
|
+
itemSnList: z.array(z.string()).describe("资源子项序列号列表"),
|
|
15
|
+
refId: z.string().optional().describe("外部系统封装过的云资源唯一标识"),
|
|
16
|
+
refType: z.enum(["FLOW"]).optional().describe("外部系统封装过的云资源类型"),
|
|
17
|
+
sn: z.string().optional().describe("资源申请对象序列号"),
|
|
18
|
+
specMap: z.record(z.object({}).passthrough()).describe("资源申请详情数据"),
|
|
19
|
+
type: z.string().describe("资源子类型"),
|
|
20
|
+
}).describe("资源申请模型");
|
|
21
|
+
// Schema for the GetMachineDeployLog API
|
|
22
|
+
export const GetMachineDeployLogRequestSchema = z.object({
|
|
23
|
+
organizationId: z.string().describe("组织ID"),
|
|
24
|
+
tunnelId: z.number().describe("隧道ID"),
|
|
25
|
+
machineSn: z.string().describe("主机序列号"),
|
|
26
|
+
});
|
|
27
|
+
export const GetMachineDeployLogResponseSchema = z.object({
|
|
28
|
+
data: DeployMachineLogSchema.optional(),
|
|
29
|
+
errorAdvice: z.string().optional(),
|
|
30
|
+
errorCode: z.string().optional(),
|
|
31
|
+
errorMap: z.record(z.object({}).passthrough()).optional(),
|
|
32
|
+
errorMessage: z.string().optional(),
|
|
33
|
+
showType: z.number().optional(),
|
|
34
|
+
success: z.boolean().optional(),
|
|
35
|
+
traceId: z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
// Schema for the AddHostListToHostGroup API
|
|
38
|
+
export const AddHostListToHostGroupRequestSchema = z.object({
|
|
39
|
+
organizationId: z.string().describe("组织ID"),
|
|
40
|
+
instanceName: z.string().describe("主机集群名称(非主机集群显示名)"),
|
|
41
|
+
hostSns: z.array(z.string()).describe("ecs主机实例id列表(主机类型暂只支持ecs)"),
|
|
42
|
+
});
|
|
43
|
+
export const AddHostListToHostGroupResponseSchema = z.boolean().describe("是否成功");
|
|
44
|
+
// Schema for the AddHostListToDeployGroup API
|
|
45
|
+
export const AddHostListToDeployGroupRequestSchema = z.object({
|
|
46
|
+
organizationId: z.string().describe("组织ID"),
|
|
47
|
+
instanceName: z.string().describe("主机集群名称(非主机集群显示名)"),
|
|
48
|
+
groupName: z.string().describe("部署组名称(非部署组显示名)"),
|
|
49
|
+
hostSns: z.array(z.string()).describe("ecs主机实例id列表(主机类型暂只支持ecs)"),
|
|
50
|
+
});
|
|
51
|
+
export const AddHostListToDeployGroupResponseSchema = z.boolean().describe("是否成功");
|
|
52
|
+
// Schema for the DeleteHostListFromDeployGroup API
|
|
53
|
+
export const DeleteHostListFromDeployGroupRequestSchema = z.object({
|
|
54
|
+
organizationId: z.string().describe("组织ID"),
|
|
55
|
+
instanceName: z.string().describe("主机集群名称(非主机集群显示名)"),
|
|
56
|
+
groupName: z.string().describe("部署组名称(非部署组显示名)"),
|
|
57
|
+
hostSns: z.array(z.string()).describe("ecs主机实例id列表(主机类型暂只支持ecs)"),
|
|
58
|
+
});
|
|
59
|
+
export const DeleteHostListFromDeployGroupResponseSchema = z.boolean().describe("是否成功");
|
|
60
|
+
// Schema for the DeleteHostListFromHostGroup API
|
|
61
|
+
export const DeleteHostListFromHostGroupRequestSchema = z.object({
|
|
62
|
+
organizationId: z.string().describe("组织ID"),
|
|
63
|
+
instanceName: z.string().describe("主机集群名称(非主机集群显示名)"),
|
|
64
|
+
hostSns: z.array(z.string()).describe("ecs主机实例id列表(主机类型暂只支持ecs)"),
|
|
65
|
+
});
|
|
66
|
+
export const DeleteHostListFromHostGroupResponseSchema = z.boolean().describe("是否成功");
|
|
67
|
+
// Schema for the GetDeployGroup API
|
|
68
|
+
export const GetDeployGroupRequestSchema = z.object({
|
|
69
|
+
organizationId: z.string().describe("组织ID"),
|
|
70
|
+
poolName: z.string().describe("资源池名称"),
|
|
71
|
+
deployGroupName: z.string().describe("部署组名称"),
|
|
72
|
+
});
|
|
73
|
+
export const GetDeployGroupResponseSchema = z.object({
|
|
74
|
+
claimList: z.array(ResourceClaimSchema).optional().describe("部署组下辖的资源申请详情列表"),
|
|
75
|
+
creatorId: z.string().optional().describe("资源实例创建者 ID"),
|
|
76
|
+
description: z.string().optional().describe("部署组描述"),
|
|
77
|
+
displayName: z.string().optional().describe("部署组的展示名"),
|
|
78
|
+
name: z.string().optional().describe("部署组的唯一名,仅允许包含小写字母、中划线和数字,且开头、结尾均为小写字母或数字"),
|
|
79
|
+
poolName: z.string().optional().describe("隶属资源池的唯一名"),
|
|
80
|
+
});
|
|
81
|
+
// Schema for the ListResourceInstances API
|
|
82
|
+
export const ListResourceInstancesRequestSchema = z.object({
|
|
83
|
+
organizationId: z.string().describe("组织ID"),
|
|
84
|
+
poolName: z.string().describe("资源池名称"),
|
|
85
|
+
pagination: z.enum(["keyset"]).optional().describe("分页模式参数,目前只支持键集分页 keyset 模式"),
|
|
86
|
+
perPage: z.number().min(1).max(100).default(20).optional().describe("分页尺寸参数,决定一页最多返回多少对象"),
|
|
87
|
+
orderBy: z.enum(["id", "gmtCreate"]).optional().describe("分页排序属性,决定根据何种属性进行记录排序;推荐在实现严格遍历时,使用 id 属性"),
|
|
88
|
+
sort: z.enum(["asc", "desc"]).optional().describe("分页排序升降序,asc 为升序,desc 为降序;推荐在实现严格遍历时,使用升序"),
|
|
89
|
+
nextToken: z.string().optional().describe("键集分页 token,获取第一页数据时无需传入,否则需要传入前一页查询结果中的 nextToken 字段"),
|
|
90
|
+
page: z.number().default(1).optional().describe("页码分页时使用,用于获取下一页内容"),
|
|
91
|
+
});
|
|
92
|
+
export const ListResourceInstancesResponseSchema = z.object({
|
|
93
|
+
current: z.number().optional().describe("页码分页时存在该字段,表示当前页"),
|
|
94
|
+
data: z.array(z.object({
|
|
95
|
+
category: z.enum(["COMPUTE"]).optional().describe("资源类别(如计算、存储、网络等)"),
|
|
96
|
+
cloudMetadata: z.string().optional().describe("云产品元数据"),
|
|
97
|
+
cloudProvider: z.string().optional().describe("云产品提供方"),
|
|
98
|
+
contextMap: z.record(z.string()).optional().describe("资源详情数据"),
|
|
99
|
+
creatorId: z.string().optional().describe("资源实例创建者 ID"),
|
|
100
|
+
description: z.string().optional().describe("资源描述"),
|
|
101
|
+
displayName: z.string().optional().describe("资源展示名"),
|
|
102
|
+
gmtCreate: z.string().optional().describe("使用本地时区呈现的应用创建时间"),
|
|
103
|
+
name: z.string().optional().describe("资源实例的唯一名,仅允许包含小写字母、中划线和数字,且开头、结尾均为小写字母或数字"),
|
|
104
|
+
poolName: z.string().optional().describe("资源池唯一名"),
|
|
105
|
+
region: z.string().optional().describe("资源所处区域"),
|
|
106
|
+
resourceGroupId: z.string().optional().describe("云产品提供方所使用的资源唯一 ID"),
|
|
107
|
+
type: z.string().optional().describe("资源子类型"),
|
|
108
|
+
})).optional().describe("分页结果数据"),
|
|
109
|
+
nextToken: z.string().nullable().optional().describe("采用键值分页时存在该字段,用于传给分页接口,迭代获取下一页数据"),
|
|
110
|
+
pages: z.number().optional().describe("页码分页时存在该字段,表示总页数"),
|
|
111
|
+
perPage: z.number().optional().describe("页码分页时存在该字段,表示每页大小"),
|
|
112
|
+
total: z.number().optional().describe("页码分页时存在该字段,表示结果总数"),
|
|
113
|
+
});
|
|
114
|
+
// Schema for the GetResourceInstance API
|
|
115
|
+
export const GetResourceInstanceRequestSchema = z.object({
|
|
116
|
+
organizationId: z.string().describe("组织ID"),
|
|
117
|
+
poolName: z.string().describe("资源池名称"),
|
|
118
|
+
instanceName: z.string().describe("资源实例名称"),
|
|
119
|
+
});
|
|
120
|
+
export const GetResourceInstanceResponseSchema = z.object({
|
|
121
|
+
category: z.enum(["COMPUTE"]).optional().describe("资源类别(如计算、存储、网络等)"),
|
|
122
|
+
cloudMetadata: z.string().optional().describe("云产品元数据"),
|
|
123
|
+
cloudProvider: z.string().optional().describe("云产品提供方"),
|
|
124
|
+
contextMap: z.record(z.string()).optional().describe("资源详情数据"),
|
|
125
|
+
creatorId: z.string().optional().describe("资源实例创建者 ID"),
|
|
126
|
+
description: z.string().optional().describe("资源描述"),
|
|
127
|
+
displayName: z.string().optional().describe("资源展示名"),
|
|
128
|
+
gmtCreate: z.string().optional().describe("使用本地时区呈现的应用创建时间"),
|
|
129
|
+
name: z.string().optional().describe("资源实例的唯一名,仅允许包含小写字母、中划线和数字,且开头、结尾均为小写字母或数字"),
|
|
130
|
+
poolName: z.string().optional().describe("资源池唯一名"),
|
|
131
|
+
region: z.string().optional().describe("资源所处区域"),
|
|
132
|
+
resourceGroupId: z.string().optional().describe("云产品提供方所使用的资源唯一 ID"),
|
|
133
|
+
type: z.string().optional().describe("资源子类型"),
|
|
134
|
+
});
|
|
135
|
+
// Schema for the UpdateResourceInstance API
|
|
136
|
+
export const UpdateResourceInstanceRequestSchema = z.object({
|
|
137
|
+
organizationId: z.string().describe("组织ID"),
|
|
138
|
+
name: z.string().describe("资源实例的唯一名,仅允许包含小写字母、中划线和数字,且开头、结尾均为小写字母或数字"),
|
|
139
|
+
kubeconfig: z.string().describe("kubeconfig配置"),
|
|
140
|
+
});
|
|
141
|
+
export const UpdateResourceInstanceResponseSchema = z.object({
|
|
142
|
+
data: z.object({
|
|
143
|
+
instanceId: z.string().optional().describe("资源实例 ID"),
|
|
144
|
+
name: z.string().optional().describe("资源实例的唯一名,仅允许包含小写字母、中划线和数字,且开头、结尾均为小写字母或数字"),
|
|
145
|
+
displayName: z.string().optional().describe("资源展示名"),
|
|
146
|
+
poolName: z.string().optional().describe("资源池唯一名"),
|
|
147
|
+
category: z.enum(["COMPUTE"]).optional().describe("资源类别(如计算、存储、网络等)"),
|
|
148
|
+
type: z.string().optional().describe("资源子类型"),
|
|
149
|
+
cloudMetadata: z.string().optional().describe("云产品元数据"),
|
|
150
|
+
cloudProvider: z.string().optional().describe("云产品提供方"),
|
|
151
|
+
contextMap: z.record(z.string()).optional().describe("资源详情数据"),
|
|
152
|
+
description: z.string().optional().describe("资源描述"),
|
|
153
|
+
region: z.string().optional().describe("资源所处区域"),
|
|
154
|
+
resourceItemList: z.array(z.object({}).passthrough()).optional().describe("资源项列表"),
|
|
155
|
+
k8s: z.boolean().optional().describe("是否k8s"),
|
|
156
|
+
host: z.boolean().optional().describe(""),
|
|
157
|
+
}).optional().describe("资源实例"),
|
|
158
|
+
errorAdvice: z.string().optional(),
|
|
159
|
+
errorCode: z.string().optional(),
|
|
160
|
+
errorMap: z.record(z.object({}).passthrough()).optional(),
|
|
161
|
+
errorMessage: z.string().optional(),
|
|
162
|
+
showType: z.number().optional(),
|
|
163
|
+
success: z.boolean().optional(),
|
|
164
|
+
traceId: z.string().optional(),
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Get machine deployment log
|
|
168
|
+
*
|
|
169
|
+
* @param params - The request parameters
|
|
170
|
+
* @returns The deployment log
|
|
171
|
+
*/
|
|
172
|
+
export async function getMachineDeployLog(params) {
|
|
173
|
+
const { organizationId, tunnelId, machineSn } = params;
|
|
174
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
175
|
+
// Build query string properly
|
|
176
|
+
const query = {};
|
|
177
|
+
if (tunnelId)
|
|
178
|
+
query.tunnelId = tunnelId;
|
|
179
|
+
if (machineSn)
|
|
180
|
+
query.machineSn = machineSn;
|
|
181
|
+
try {
|
|
182
|
+
const baseUrl = isRegionEdition()
|
|
183
|
+
? `/oapi/v1/appstack/host/deployLog`
|
|
184
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/host/deployLog`;
|
|
185
|
+
const url = buildUrl(baseUrl, query);
|
|
186
|
+
const response = await yunxiaoRequest(url, {
|
|
187
|
+
method: 'GET',
|
|
188
|
+
});
|
|
189
|
+
return GetMachineDeployLogResponseSchema.parse(response);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Add host list to host group
|
|
197
|
+
*
|
|
198
|
+
* @param params - The request parameters
|
|
199
|
+
* @returns Whether the operation was successful
|
|
200
|
+
*/
|
|
201
|
+
export async function addHostListToHostGroup(params) {
|
|
202
|
+
const { organizationId, instanceName, ...body } = params;
|
|
203
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
204
|
+
try {
|
|
205
|
+
const url = isRegionEdition()
|
|
206
|
+
? `/oapi/v1/appstack/pools/instances/${instanceName}/addHostList`
|
|
207
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/pools/instances/${instanceName}/addHostList`;
|
|
208
|
+
const response = await yunxiaoRequest(url, {
|
|
209
|
+
method: 'PUT',
|
|
210
|
+
body: body,
|
|
211
|
+
});
|
|
212
|
+
return AddHostListToHostGroupResponseSchema.parse(response);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Add host list to deploy group
|
|
220
|
+
*
|
|
221
|
+
* @param params - The request parameters
|
|
222
|
+
* @returns Whether the operation was successful
|
|
223
|
+
*/
|
|
224
|
+
export async function addHostListToDeployGroup(params) {
|
|
225
|
+
const { organizationId, instanceName, groupName, ...body } = params;
|
|
226
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
227
|
+
try {
|
|
228
|
+
const url = isRegionEdition()
|
|
229
|
+
? `/oapi/v1/appstack/pools/instances/${instanceName}/deployGroup/${groupName}/addHostList`
|
|
230
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/pools/instances/${instanceName}/deployGroup/${groupName}/addHostList`;
|
|
231
|
+
const response = await yunxiaoRequest(url, {
|
|
232
|
+
method: 'PUT',
|
|
233
|
+
body: body,
|
|
234
|
+
});
|
|
235
|
+
return AddHostListToDeployGroupResponseSchema.parse(response);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Delete host list from deploy group
|
|
243
|
+
*
|
|
244
|
+
* @param params - The request parameters
|
|
245
|
+
* @returns Whether the operation was successful
|
|
246
|
+
*/
|
|
247
|
+
export async function deleteHostListFromDeployGroup(params) {
|
|
248
|
+
const { organizationId, instanceName, groupName, ...body } = params;
|
|
249
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
250
|
+
try {
|
|
251
|
+
const url = isRegionEdition()
|
|
252
|
+
? `/oapi/v1/appstack/pools/instances/${instanceName}/deployGroup/${groupName}/removeHostList`
|
|
253
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/pools/instances/${instanceName}/deployGroup/${groupName}/removeHostList`;
|
|
254
|
+
const response = await yunxiaoRequest(url, {
|
|
255
|
+
method: 'PUT',
|
|
256
|
+
body: body,
|
|
257
|
+
});
|
|
258
|
+
return DeleteHostListFromDeployGroupResponseSchema.parse(response);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Delete host list from host group
|
|
266
|
+
*
|
|
267
|
+
* @param params - The request parameters
|
|
268
|
+
* @returns Whether the operation was successful
|
|
269
|
+
*/
|
|
270
|
+
export async function deleteHostListFromHostGroup(params) {
|
|
271
|
+
const { organizationId, instanceName, ...body } = params;
|
|
272
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
273
|
+
try {
|
|
274
|
+
const url = isRegionEdition()
|
|
275
|
+
? `/oapi/v1/appstack/pools/instances/${instanceName}/removeHostList`
|
|
276
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/pools/instances/${instanceName}/removeHostList`;
|
|
277
|
+
const response = await yunxiaoRequest(url, {
|
|
278
|
+
method: 'PUT',
|
|
279
|
+
body: body,
|
|
280
|
+
});
|
|
281
|
+
return DeleteHostListFromHostGroupResponseSchema.parse(response);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { yunxiaoRequest, buildUrl, isRegionEdition } from '../../common/utils.js';
|
|
3
|
+
import { resolveOrganizationId } from '../organization/organization.js';
|
|
4
|
+
// Define the referenced schemas based on their usage
|
|
5
|
+
const VariableSchema = z.object({
|
|
6
|
+
key: z.string().optional().describe("变量键"),
|
|
7
|
+
value: z.string().optional().describe("变量值"),
|
|
8
|
+
description: z.string().optional().describe("变量描述"),
|
|
9
|
+
}).describe("变量");
|
|
10
|
+
const RevisionSchema = z.object({
|
|
11
|
+
author: z.string().optional().describe("提交人"),
|
|
12
|
+
commitTime: z.number().optional().describe("提交时间 (毫秒时间戳)"),
|
|
13
|
+
message: z.string().optional().describe("版本提交信息"),
|
|
14
|
+
refs: z.array(z.string()).optional().describe("关联信息"),
|
|
15
|
+
sha: z.string().optional().describe("版本sha值"),
|
|
16
|
+
}).describe("版本信息");
|
|
17
|
+
const GlobalVarVOSchema = z.object({
|
|
18
|
+
name: z.string().optional().describe("全局变量组名称"),
|
|
19
|
+
displayName: z.string().optional().describe("全局变量组显示名称"),
|
|
20
|
+
creator: z.string().optional().describe("全局变量组创建者"),
|
|
21
|
+
gmtCreate: z.string().optional().describe("全局变量组创建时间"),
|
|
22
|
+
gmtModified: z.string().optional().describe("全局变量组修改时间"),
|
|
23
|
+
modifier: z.string().optional().describe("全局变量组修改者"),
|
|
24
|
+
}).describe("全局变量组VO");
|
|
25
|
+
// Schema for the CreateGlobalVar API
|
|
26
|
+
export const CreateGlobalVarRequestSchema = z.object({
|
|
27
|
+
organizationId: z.string().describe("组织ID"),
|
|
28
|
+
displayName: z.string().describe("全局变量组显示名称"),
|
|
29
|
+
name: z.string().describe("全局变量组名称"),
|
|
30
|
+
content: z.array(VariableSchema).optional().describe("变量列表"),
|
|
31
|
+
message: z.string().optional().describe("全局变量组信息"),
|
|
32
|
+
ownerId: z.string().optional().describe("全局变量组拥有者"),
|
|
33
|
+
});
|
|
34
|
+
export const CreateGlobalVarResponseSchema = z.object({
|
|
35
|
+
content: z.array(VariableSchema).optional().describe("全局变量组变量列表"),
|
|
36
|
+
creator: z.string().optional().describe("全局变量组创建者"),
|
|
37
|
+
displayName: z.string().optional().describe("全局变量组显示名称"),
|
|
38
|
+
gmtCreate: z.string().optional().describe("全局变量组创建时间"),
|
|
39
|
+
gmtModified: z.string().optional().describe("全局变量组修改时间"),
|
|
40
|
+
modifier: z.string().optional().describe("全局变量组修改者"),
|
|
41
|
+
name: z.string().optional().describe("全局变量组名称"),
|
|
42
|
+
revision: RevisionSchema.optional().describe("版本信息"),
|
|
43
|
+
});
|
|
44
|
+
// Schema for the DeleteGlobalVar API
|
|
45
|
+
export const DeleteGlobalVarRequestSchema = z.object({
|
|
46
|
+
organizationId: z.string().describe("组织ID"),
|
|
47
|
+
name: z.string().describe("全局变量组名称"),
|
|
48
|
+
});
|
|
49
|
+
export const DeleteGlobalVarResponseSchema = z.boolean().describe("调用是否成功");
|
|
50
|
+
// Schema for the GetGlobalVar API
|
|
51
|
+
export const GetGlobalVarRequestSchema = z.object({
|
|
52
|
+
organizationId: z.string().describe("组织ID"),
|
|
53
|
+
name: z.string().describe("全局变量组名称"),
|
|
54
|
+
revisionSha: z.string().optional().describe("全局变量组版本"),
|
|
55
|
+
});
|
|
56
|
+
export const GetGlobalVarResponseSchema = z.object({
|
|
57
|
+
content: z.array(VariableSchema).optional().describe("全局变量组变量列表"),
|
|
58
|
+
creator: z.string().optional().describe("全局变量组创建者"),
|
|
59
|
+
displayName: z.string().optional().describe("全局变量组显示名称"),
|
|
60
|
+
gmtCreate: z.string().optional().describe("全局变量组创建时间"),
|
|
61
|
+
gmtModified: z.string().optional().describe("全局变量组修改时间"),
|
|
62
|
+
modifier: z.string().optional().describe("全局变量组修改者"),
|
|
63
|
+
name: z.string().optional().describe("全局变量组名称"),
|
|
64
|
+
revision: RevisionSchema.optional().describe("版本信息"),
|
|
65
|
+
});
|
|
66
|
+
// Schema for the UpdateGlobalVar API
|
|
67
|
+
export const UpdateGlobalVarRequestSchema = z.object({
|
|
68
|
+
organizationId: z.string().describe("组织ID"),
|
|
69
|
+
name: z.string().describe("全局变量组名称"),
|
|
70
|
+
content: z.array(VariableSchema).describe("变量列表"),
|
|
71
|
+
fromRevisionSha: z.string().describe("更新源版本信息"),
|
|
72
|
+
message: z.string().optional().describe("全局变量组信息"),
|
|
73
|
+
});
|
|
74
|
+
export const UpdateGlobalVarResponseSchema = z.object({
|
|
75
|
+
content: z.array(VariableSchema).optional().describe("全局变量组变量列表"),
|
|
76
|
+
creator: z.string().optional().describe("全局变量组创建者"),
|
|
77
|
+
displayName: z.string().optional().describe("全局变量组显示名称"),
|
|
78
|
+
gmtCreate: z.string().optional().describe("全局变量组创建时间"),
|
|
79
|
+
gmtModified: z.string().optional().describe("全局变量组修改时间"),
|
|
80
|
+
modifier: z.string().optional().describe("全局变量组修改者"),
|
|
81
|
+
name: z.string().optional().describe("全局变量组名称"),
|
|
82
|
+
revision: RevisionSchema.optional().describe("版本信息"),
|
|
83
|
+
});
|
|
84
|
+
// Schema for the ListGlobalVars API
|
|
85
|
+
export const ListGlobalVarsRequestSchema = z.object({
|
|
86
|
+
organizationId: z.string().describe("组织ID"),
|
|
87
|
+
current: z.number().describe("当前页码"),
|
|
88
|
+
pageSize: z.number().describe("每页大小"),
|
|
89
|
+
search: z.string().optional().describe("查询关键字"),
|
|
90
|
+
});
|
|
91
|
+
export const ListGlobalVarsResponseSchema = z.object({
|
|
92
|
+
current: z.number().describe("当前页数"),
|
|
93
|
+
pageSize: z.number().describe("每页大小"),
|
|
94
|
+
pages: z.number().describe("总页数"),
|
|
95
|
+
records: z.array(GlobalVarVOSchema).describe("数据列表"),
|
|
96
|
+
total: z.number().describe("总数"),
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Create a global variable group
|
|
100
|
+
*
|
|
101
|
+
* @param params - The request parameters
|
|
102
|
+
* @returns The created global variable group
|
|
103
|
+
*/
|
|
104
|
+
export async function createGlobalVar(params) {
|
|
105
|
+
const { organizationId, ...body } = params;
|
|
106
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
107
|
+
try {
|
|
108
|
+
const url = isRegionEdition()
|
|
109
|
+
? `/oapi/v1/appstack/globalVars`
|
|
110
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/globalVars`;
|
|
111
|
+
const response = await yunxiaoRequest(url, {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
body: body,
|
|
114
|
+
});
|
|
115
|
+
return CreateGlobalVarResponseSchema.parse(response);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Delete a global variable group
|
|
123
|
+
*
|
|
124
|
+
* @param params - The request parameters
|
|
125
|
+
* @returns Whether the deletion was successful
|
|
126
|
+
*/
|
|
127
|
+
export async function deleteGlobalVar(params) {
|
|
128
|
+
const { organizationId, name } = params;
|
|
129
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
130
|
+
try {
|
|
131
|
+
const url = isRegionEdition()
|
|
132
|
+
? `/oapi/v1/appstack/globalVars/${name}`
|
|
133
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/globalVars/${name}`;
|
|
134
|
+
const response = await yunxiaoRequest(url, {
|
|
135
|
+
method: 'DELETE',
|
|
136
|
+
});
|
|
137
|
+
return DeleteGlobalVarResponseSchema.parse(response);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get a global variable group
|
|
145
|
+
*
|
|
146
|
+
* @param params - The request parameters
|
|
147
|
+
* @returns The global variable group
|
|
148
|
+
*/
|
|
149
|
+
export async function getGlobalVar(params) {
|
|
150
|
+
const { organizationId, name, revisionSha } = params;
|
|
151
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
152
|
+
// Build query string properly
|
|
153
|
+
const query = {};
|
|
154
|
+
if (revisionSha)
|
|
155
|
+
query.revisionSha = revisionSha;
|
|
156
|
+
try {
|
|
157
|
+
const baseUrl = isRegionEdition()
|
|
158
|
+
? `/oapi/v1/appstack/globalVars/${name}`
|
|
159
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/globalVars/${name}`;
|
|
160
|
+
const url = buildUrl(baseUrl, query);
|
|
161
|
+
const response = await yunxiaoRequest(url, {
|
|
162
|
+
method: 'GET',
|
|
163
|
+
});
|
|
164
|
+
return GetGlobalVarResponseSchema.parse(response);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Update a global variable group
|
|
172
|
+
*
|
|
173
|
+
* @param params - The request parameters
|
|
174
|
+
* @returns The updated global variable group
|
|
175
|
+
*/
|
|
176
|
+
export async function updateGlobalVar(params) {
|
|
177
|
+
const { organizationId, name, ...body } = params;
|
|
178
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
179
|
+
try {
|
|
180
|
+
const url = isRegionEdition()
|
|
181
|
+
? `/oapi/v1/appstack/globalVars/${name}`
|
|
182
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/globalVars/${name}`;
|
|
183
|
+
const response = await yunxiaoRequest(url, {
|
|
184
|
+
method: 'PUT',
|
|
185
|
+
body: body,
|
|
186
|
+
});
|
|
187
|
+
return UpdateGlobalVarResponseSchema.parse(response);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* List global variable groups
|
|
195
|
+
*
|
|
196
|
+
* @param params - The request parameters
|
|
197
|
+
* @returns The list of global variable groups
|
|
198
|
+
*/
|
|
199
|
+
export async function listGlobalVars(params) {
|
|
200
|
+
const { organizationId, current, pageSize, search } = params;
|
|
201
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
202
|
+
// Build query string properly
|
|
203
|
+
const query = {
|
|
204
|
+
current: current,
|
|
205
|
+
pageSize: pageSize
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
const baseUrl = isRegionEdition()
|
|
209
|
+
? `/oapi/v1/appstack/globalVars:search`
|
|
210
|
+
: `/oapi/v1/appstack/organizations/${finalOrgId}/globalVars:search`;
|
|
211
|
+
const url = buildUrl(baseUrl, query);
|
|
212
|
+
const response = await yunxiaoRequest(url, {
|
|
213
|
+
method: 'POST',
|
|
214
|
+
body: { search },
|
|
215
|
+
});
|
|
216
|
+
return ListGlobalVarsResponseSchema.parse(response);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|