[ PROMPT_NODE_24318 ]
Spectrum API 参考
[ SKILL_DOCUMENTATION ]
## REST API 端点
GET /zones/{zone_id}/spectrum/apps # 列出应用
POST /zones/{zone_id}/spectrum/apps # 创建应用
GET /zones/{zone_id}/spectrum/apps/{app_id} # 获取应用
PUT /zones/{zone_id}/spectrum/apps/{app_id} # 更新应用
DELETE /zones/{zone_id}/spectrum/apps/{app_id} # 删除应用
GET /zones/{zone_id}/spectrum/analytics/aggregate/current
GET /zones/{zone_id}/spectrum/analytics/events/bytime
GET /zones/{zone_id}/spectrum/analytics/events/summary
## 请求/响应模式
### CreateSpectrumAppRequest
typescript
interface CreateSpectrumAppRequest {
protocol: string; // "tcp/22", "udp/53"
dns: {
type: "CNAME" | "ADDRESS";
name: string; // "ssh.example.com"
};
origin_direct?: string[]; // ["tcp://192.0.2.1:22"]
origin_dns?: { name: string }; // {"name": "origin.example.com"}
origin_port?: number | { start: number; end: number };
proxy_protocol?: "off" | "v1" | "v2" | "simple";
ip_firewall?: boolean;
tls?: "off" | "flexible" | "full" | "strict";
edge_ips?: {
type: "dynamic" | "static";
connectivity: "all" | "ipv4" | "ipv6";
};
traffic_type?: "direct" | "http" | "https";
argo_smart_routing?: boolean;
}
### SpectrumApp 响应
typescript
interface SpectrumApp {
id: string;
protocol: string;
dns: { type: string; name: string };
origin_direct?: string[];
origin_dns?: { name: string };
origin_port?: number | { start: number; end: number };
proxy_protocol: string;
ip_firewall: boolean;
tls: string;
edge_ips: { type: string; connectivity: string; ips?: string[] };
argo_smart_routing: boolean;
created_on: string;
modified_on: string;
}
## TypeScript SDK
typescript
import Cloudflare from 'cloudflare';
const client = new Cloudflare({ apiToken: process.env.CLOUDFLARE_API_TOKEN });
// 创建
const app = await client.spectrum.apps.create({
zone_id: 'your-zone-id',
protocol: 'tcp/22',
dns: { type: 'CNAME', name: 'ssh.example.com' },
origin_direct: ['tcp://192.0.2.1:22'],
ip_firewall: true,
tls: 'off',
});
// 列出
const apps = await client.spectrum.apps.list({ zone_id: 'your-zone-id' });
// 获取
const appDetails = await client.spectrum.apps.get({ zone_id: 'your-zone-id', app_id: app.id });
// 更新
await client.spectrum.apps.update({ zone_id: 'your-zone-id', app_id: app.id, tls: 'full' });
// 删除
await c