概述
ClawOps API 提供了完整的运维自动化接口,支持通过 RESTful API 调用所有 Skill 能力。
基础 URL
# 以下为 ClawOps 历史设计地址,当前未开放公有服务 https://api.clawops.cloudmesh.top/v1 https://api-staging.clawops.cloudmesh.top/v1 # 开源 ITSM 可用接口(本地启动后) http://localhost:8090/api/v1 http://localhost:8090/swagger/index.html
请求格式
- Content-Type: application/json
- 编码: UTF-8
- 认证: Bearer Token
认证
API Key 认证
所有 API 请求需要在 Header 中携带 API Key
curl -X GET "https://api.clawops.cloudmesh.top/v1/servers" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json"
获取 API Key
- 登录 ClawOps 控制台
- 进入「设置」→「API 管理」
- 点击「创建 API Key」
- 设置权限范围和过期时间
网络 Skill API
GET
/network/topology
获取网络拓扑结构
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| region | string | 是 | 区域标识 |
| depth | integer | 否 | 拓扑深度,默认 3 |
| format | string | 否 | 输出格式:json/graphml,默认 json |
响应示例
{
"code": 200,
"data": {
"nodes": [
{
"id": "sw-001",
"type": "switch",
"name": "核心交换机-01",
"ip": "192.168.1.1",
"vendor": "huawei",
"status": "online"
}
],
"edges": [
{
"source": "sw-001",
"target": "sw-002",
"bandwidth": "10G"
}
]
}
}
POST
/network/diagnose
网络故障诊断
请求体
{
"source": "192.168.1.100",
"target": "192.168.2.100",
"checks": ["ping", "traceroute", "port"],
"ports": [80, 443, 3306]
}
POST
/network/config/audit
设备配置审计
请求体
{
"devices": ["sw-001", "sw-002"],
"rules": ["ssh-version", "password-policy", "acl-compliance"],
"autoFix": false
}
DBA Skill API
POST
/dba/slow-query/analyze
慢查询分析
请求体
{
"instanceId": "mysql-prod-01",
"timeRange": {
"start": "2026-03-20T00:00:00Z",
"end": "2026-03-23T00:00:00Z"
},
"topN": 10,
"minExecutionTime": 1
}
响应示例
{
"code": 200,
"data": {
"total": 156,
"queries": [
{
"fingerprint": "SELECT * FROM orders WHERE ...",
"count": 1234,
"avgTime": 3.2,
"maxTime": 15.6,
"suggestion": "添加索引 idx_create_time"
}
]
}
}
POST
/dba/sql/optimize
SQL 优化建议
请求体
{
"instanceId": "mysql-prod-01",
"sql": "SELECT * FROM orders WHERE user_id = ? AND status = ?",
"analyzeExecutionPlan": true
}
GET
/dba/capacity/predict
容量预测
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| instanceId | string | 是 | 实例 ID |
| days | integer | 否 | 预测天数,默认 30 |
SRE Skill API
POST
/sre/alerts/aggregate
告警聚合分析
请求体
{
"timeRange": "1h",
"groupBy": ["service", "alertName"],
"correlationThreshold": 0.8,
"includeSuggestions": true
}
POST
/sre/rca/analyze
根因分析
请求体
{
"incidentId": "INC-20260323-001",
"depth": "deep",
"includeTimeline": true,
"includeSuggestions": true
}
GET
/sre/sla/report
SLA 报告
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| service | string | 否 | 服务名称,不传则返回全部 |
| period | string | 否 | 时间周期:day/week/month |
| format | string | 否 | 输出格式:json/pdf |
安全 Skill API
POST
/security/vulnerability/scan
漏洞扫描
请求体
{
"targets": ["192.168.1.0/24"],
"scanType": ["system", "web", "database"],
"severity": ["critical", "high", "medium"],
"notifyOnComplete": true
}
POST
/security/compliance/check
合规检查
请求体
{
"standard": "mlps-level3",
"scope": "all",
"generateReport": true
}
DevOps Skill API
POST
/devops/deploy
应用部署
请求体
{
"service": "pay-service",
"version": "v2.3.1",
"environment": "staging",
"strategy": "rolling",
"replicas": 3,
"healthCheck": {
"enabled": true,
"path": "/health",
"timeout": 30
}
}
POST
/devops/rollback
应用回滚
请求体
{
"service": "pay-service",
"environment": "production",
"targetVersion": "v2.2.5",
"reason": "性能问题"
}
审计 Skill API
POST
/audit/logs/query
审计日志查询
请求体
{
"timeRange": {
"start": "2026-03-20T00:00:00Z",
"end": "2026-03-23T00:00:00Z"
},
"filters": {
"user": "admin",
"action": "ssh_login",
"result": "success"
},
"pagination": {
"page": 1,
"pageSize": 100
}
}
POST
/audit/report/generate
生成审计报告
请求体
{
"template": "monthly-audit",
"period": "2026-03",
"format": "pdf",
"includeRawData": false
}
错误码
| 错误码 | 说明 | 解决方案 |
|---|---|---|
| 401 | 认证失败 | 检查 API Key 是否正确 |
| 403 | 权限不足 | 检查 API Key 权限范围 |
| 404 | 资源不存在 | 检查请求的资源 ID |
| 429 | 请求频率超限 | 降低请求频率或联系客服 |
| 500 | 服务器内部错误 | 重试或联系技术支持 |
| 503 | 服务暂时不可用 | 稍后重试 |
这篇文档对你有帮助吗?