---
description: cloudflare相关的说明
globs: 
alwaysApply: false
---

# Cloudflare 域管理及DNS管理功能
- cloudflare的统一返回结构体为
{
    "result": any,
    "result_info": {
        "page": 1,
        "per_page": 20,
        "total_pages": 1,
        "count": 1,
        "total_count": 1
    },
    "success": true,
    "errors": [
       {
            "code": 6003,
            "message": "Invalid request headers",
            "error_chain": [
                {
                    "code": 6111,
                    "message": "Invalid format for Authorization header"
                }
            ]
        }
    ],
    "messages": []
}


## domain管理功能

### domain的查询功能
- 返回结构体如下
{
    "result": [
        {
            "id": "511894a4f1357feb905e974e16241ebb",
            "name": "107421.xyz",
            "status": "active",
            "paused": false,
            "type": "full",
            "development_mode": 0,
            "name_servers": [
                "ali.ns.cloudflare.com",
                "walt.ns.cloudflare.com"
            ],
            "original_name_servers": [
                "ns1.dnsowl.com",
                "ns2.dnsowl.com",
                "ns3.dnsowl.com"
            ],
            "original_registrar": null,
            "original_dnshost": null,
            "modified_on": "2021-11-03T01:47:42.506130Z",
            "created_on": "2021-11-03T01:33:07.447056Z",
            "activated_on": "2021-11-03T01:47:42.506130Z",
            "meta": {
                "step": 2,
                "custom_certificate_quota": 0,
                "page_rule_quota": 3,
                "phishing_detected": false
            },
            "owner": {
                "id": null,
                "type": "user",
                "email": null
            },
            "account": {
                "id": "dfaadeb83406ef5ad35da02617af9191",
                "name": "Zeaslity@gmail.com's Account"
            },
            "tenant": {
                "id": null,
                "name": null
            },
            "tenant_unit": {
                "id": null
            },
            "permissions": [
                "#zone:read",
                "#zone_settings:read",
                "#dns_records:edit",
                "#dns_records:read"
            ],
            "plan": {
                "id": "0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                "name": "Free Website",
                "price": 0,
                "currency": "USD",
                "frequency": "",
                "is_subscribed": false,
                "can_subscribe": false,
                "legacy_id": "free",
                "legacy_discount": false,
                "externally_managed": false
            }
        }
    ],
    "result_info": {
        "page": 1,
        "per_page": 20,
        "total_pages": 1,
        "count": 1,
        "total_count": 1
    },
    "success": true,
    "errors": [],
    "messages": []
}


## DNS管理功能实现
- 需要实现特定domain的DNS的管理
- 参考文档 https://developers.cloudflare.com/api/resources/dns/subresources/records/

### 查询全部DNS记录
- 单条DNS记录的结构体如下 {
          "id": "b940757dfd94e8e2941e2ec1b2ee0515",
          "name": "mail.107421.xyz",
          "type": "MX",
          "content": "mx2.yuanyoupush.com",
          "priority": 20,
          "proxiable": false,
          "proxied": false,
          "ttl": 1,
          "settings": {},
          "meta": {},
          "comment": "全自动邮箱",
          "tags": [],
          "created_on": "2025-03-15T05:56:37.296599Z",
          "modified_on": "2025-03-15T05:57:08.180765Z",
          "comment_modified_on": "2025-03-15T05:56:37.296599Z"
      },

### 更新某个DNS记录

### 删除某个DNS记录

### 新增一个DNS记录
