Files
DNSPod-Skill/scripts/delete_record.py
OpenClaw c420f5a4cd Initial commit: Tencent DNSPod DNS deployment skill
Features:
- Single record deployment (A/CNAME/MX/TXT records)
- Batch deployment from JSON configuration
- Quick service deployment (Web/API/CDN)
- .env file support for secure credential management
- Complete documentation with installation guide
- Error handling and troubleshooting guide

Scripts:
- deploy_record.py - Single record management
- batch_deploy.py - Batch deployment from config
- deploy_service.py - Quick service templates
- list_records.py - Query existing records
- delete_record.py - Remove DNS records

Documentation:
- SKILL.md - Main skill documentation
- INSTALL.md - Installation and quick start
- ENV_SETUP.md - Environment configuration guide
- README.md - Project overview
- references/api-auth.md - API authentication details
- references/common-errors.md - Error handling
- examples/dns-config.json - Batch deployment example
2026-03-01 11:51:33 +08:00

69 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python3
"""
DNS记录删除脚本
"""
import os
import sys
from deploy_record import (
call_api,
find_record,
load_env
)
# 加载 .env
load_env()
def delete_record(domain, subdomain, record_type):
"""删除DNS记录"""
print(f"\n删除DNS记录: {subdomain or '@'}.{domain} ({record_type})")
# 查找记录
record = find_record(domain, subdomain, record_type)
if not record:
print(f"✗ 记录不存在")
return False
record_id = record.get("RecordId")
current_value = record.get("Value")
print(f" 记录ID: {record_id}")
print(f" 当前值: {current_value}")
# 确认删除
response = input("\n确认删除? (y/N): ")
if response.lower() != 'y':
print(" 已取消")
return False
# 调用删除API
try:
params = {
"Domain": domain,
"RecordId": record_id
}
result = call_api("DeleteRecord", params)
print(f"✓ 记录删除成功")
return True
except Exception as e:
print(f"✗ 记录删除失败: {e}")
return False
def main():
import argparse
parser = argparse.ArgumentParser(description='删除DNS记录')
parser.add_argument('--domain', required=True, help='域名(如: example.com)')
parser.add_argument('--subdomain', default='@', help='子域名(默认: @)')
parser.add_argument('--type', required=True, help='记录类型(A/CNAME/MX等)')
args = parser.parse_args()
success = delete_record(args.domain, args.subdomain, args.type)
sys.exit(0 if success else 1)
if __name__ == '__main__':
main()