feat: 新增 lightcore-cli 命令行工具项目

新增完整的 lightcore-cli 命令行工具代码,包含:
- CLI 入口与参数解析
- System 和 Media 应用的客户端实现
- 丰富的子命令与操作接口
- 测试用例与项目配置
- .gitignore 与 README 文档
This commit is contained in:
2026-11-20 01:35:46 +08:00
commit 3eb720cfbd
17 changed files with 2862 additions and 0 deletions
+597
View File
@@ -0,0 +1,597 @@
"""Request fields for the existing System Admin HTTP DTOs."""
REQUESTS = {
"AdminOperationLogDetailReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
},
"required": ["id"],
},
"AdminOperationLogListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "default": 20},
"operationKey": {"type": "string"},
"resultStatus": {"type": "string", "enum": ["pending", "success", "fail", "unknown"]},
"adminId": {"type": "integer"},
"resourceType": {"type": "string"},
"resourceId": {"type": "integer"},
"traceId": {"type": "string"},
"startTime": {"type": "string"},
"endTime": {"type": "string"},
},
"required": [],
},
"AliyunDNSAccountCreateReq": {
"properties": {
"name": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "disabled"]},
"accessKeyId": {"type": "string", "maxLength": 128},
"accessKeySecret": {"type": "string", "maxLength": 256},
},
"required": ["name", "status", "accessKeyId", "accessKeySecret"],
},
"AliyunDNSAccountCredentialReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"AliyunDNSAccountDeleteReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"version": {"type": "integer", "minimum": 1},
},
"required": ["id", "version"],
},
"AliyunDNSAccountListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "disabled"]},
"healthStatus": {"type": "string", "enum": ["unknown", "healthy", "unhealthy"]},
},
"required": ["pageNo", "pageSize"],
},
"AliyunDNSAccountReplaceCredentialReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"version": {"type": "integer", "minimum": 1},
"accessKeyId": {"type": "string", "maxLength": 128},
"accessKeySecret": {"type": "string", "maxLength": 256},
},
"required": ["id", "version", "accessKeyId", "accessKeySecret"],
},
"AliyunDNSAccountStatusReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"version": {"type": "integer", "minimum": 1},
"status": {"type": "string", "enum": ["active", "disabled"]},
},
"required": ["id", "version", "status"],
},
"AliyunDNSAccountUpdateReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"version": {"type": "integer", "minimum": 1},
"name": {"type": "string", "maxLength": 120},
},
"required": ["id", "version", "name"],
},
"AliyunDNSAccountValidateReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"AliyunDNSDomainListReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 253},
},
"required": ["accountId", "pageNo", "pageSize"],
},
"AliyunDNSRecordDeleteReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
"recordId": {"type": "string"},
},
"required": ["accountId", "domainName", "recordId"],
},
"AliyunDNSRecordListReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"rr": {"type": "string", "maxLength": 253},
"type": {"type": "string", "maxLength": 16},
"value": {"type": "string", "maxLength": 2048},
"status": {"type": "string", "enum": ["ENABLE", "DISABLE"]},
},
"required": ["accountId", "domainName", "pageNo", "pageSize"],
},
"AliyunDNSRecordMutationReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
"rr": {"type": "string", "maxLength": 253},
"type": {"type": "string", "enum": ["A", "AAAA", "CNAME", "TXT", "MX", "NS", "SRV", "CAA"]},
"value": {"type": "string", "maxLength": 2048},
"ttl": {"type": "integer", "minimum": 1},
"priority": {"type": "integer", "minimum": 0, "maximum": 50},
"line": {"type": "string", "const": "default"},
},
"required": ["accountId", "domainName", "rr", "type", "value", "ttl", "line"],
},
"AliyunDNSRecordOptionsReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
},
"required": ["accountId", "domainName"],
},
"AliyunDNSRecordStatusReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
"recordId": {"type": "string"},
"status": {"type": "string", "enum": ["ENABLE", "DISABLE"]},
},
"required": ["accountId", "domainName", "recordId", "status"],
},
"AliyunDNSRecordUpdateReq": {
"properties": {
"accountId": {"type": "string", "format": "uuid"},
"domainName": {"type": "string", "maxLength": 253},
"rr": {"type": "string", "maxLength": 253},
"type": {"type": "string", "enum": ["A", "AAAA", "CNAME", "TXT", "MX", "NS", "SRV", "CAA"]},
"value": {"type": "string", "maxLength": 2048},
"ttl": {"type": "integer", "minimum": 1},
"priority": {"type": "integer", "minimum": 0, "maximum": 50},
"line": {"type": "string", "const": "default"},
"recordId": {"type": "string"},
},
"required": ["accountId", "domainName", "rr", "type", "value", "ttl", "line", "recordId"],
},
"CreateFieldCheckTaskReq": {
"properties": {
"tables": {"type": "array", "minItems": 1, "items": {"type": "string"}},
},
"required": ["tables"],
},
"CreateModuleTaskReq": {
"properties": {
"modules": {"type": "array", "minItems": 1, "items": {"type": "string"}},
},
"required": ["modules"],
},
"CreateSmartTaskReq": {
"properties": {
"modules": {"type": "array", "minItems": 1, "items": {"type": "string"}},
},
"required": ["modules"],
},
"CreateTableTaskReq": {
"properties": {
"tables": {"type": "array", "minItems": 1, "items": {"type": "string"}},
},
"required": ["tables"],
},
"DirectoryCreateReq": {
"properties": {
"name": {"type": "string", "maxLength": 100},
"parentId": {"type": "integer"},
},
"required": ["name"],
},
"DirectoryDeleteReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
},
"required": ["id"],
},
"DirectoryUpdateReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
"name": {"type": "string", "maxLength": 100},
},
"required": ["id", "name"],
},
"DownloadFromUrlReq": {
"properties": {
"url": {"type": "string", "format": "uri"},
"path": {"type": "string"},
},
"required": ["url"],
},
"LightCoreStorageBucketCreateReq": {
"properties": {
"name": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "read_only", "disabled"]},
"originIds": {"type": "array", "minItems": 1, "items": {"type": "string", "format": "uuid"}},
},
"required": ["name", "status", "originIds"],
},
"LightCoreStorageBucketDetailReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageBucketListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "read_only", "disabled"]},
},
"required": ["pageNo", "pageSize"],
},
"LightCoreStorageBucketStatusReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"status": {"type": "string", "enum": ["active", "read_only", "disabled"]},
},
"required": ["id", "status"],
},
"LightCoreStorageBucketUpdateRouteReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"originIds": {"type": "array", "minItems": 1, "items": {"type": "string", "format": "uuid"}},
},
"required": ["id", "originIds"],
},
"LightCoreStorageClientCreateReq": {
"properties": {
"clientName": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "disabled"]},
"grants": {"type": "array", "minItems": 1, "items": {"type": "object", "properties": {"bucketId": {"type": "string", "format": "uuid"}, "canRead": {"type": "boolean"}, "canWrite": {"type": "boolean"}, "canDelete": {"type": "boolean"}}, "required": ["bucketId"]}},
},
"required": ["clientName", "status", "grants"],
},
"LightCoreStorageClientDetailReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageClientListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "disabled"]},
},
"required": ["pageNo", "pageSize"],
},
"LightCoreStorageClientNameReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"clientName": {"type": "string", "maxLength": 120},
},
"required": ["id", "clientName"],
},
"LightCoreStorageClientReplaceGrantsReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"grants": {"type": "array", "minItems": 1, "items": {"type": "object", "properties": {"bucketId": {"type": "string", "format": "uuid"}, "canRead": {"type": "boolean"}, "canWrite": {"type": "boolean"}, "canDelete": {"type": "boolean"}}, "required": ["bucketId"]}},
},
"required": ["id", "grants"],
},
"LightCoreStorageClientSecretReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageClientStatusReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"status": {"type": "string", "enum": ["active", "disabled"]},
},
"required": ["id", "status"],
},
"LightCoreStorageObjectActionReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageObjectDetailReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageObjectListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"bucketId": {"type": "string", "format": "uuid"},
"clientId": {"type": "string", "format": "uuid"},
"originId": {"type": "string", "format": "uuid"},
"status": {"type": "string", "enum": ["pending", "active", "upload_failed", "deleting", "delete_failed", "deleted"]},
"mimeType": {"type": "string", "maxLength": 255},
"startAt": {"type": "string"},
"endAt": {"type": "string"},
},
"required": ["pageNo", "pageSize"],
},
"LightCoreStorageObjectURLReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"expiresInSeconds": {"type": "integer", "minimum": 60, "maximum": 86400},
},
"required": ["id"],
},
"LightCoreStorageOriginActionReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageOriginCreateReq": {
"properties": {
"name": {"type": "string", "maxLength": 120},
"provider": {"type": "string", "enum": ["alioss", "tencent_cos", "qiniu", "aws_s3", "minio"]},
"status": {"type": "string", "enum": ["active", "disabled"]},
"accessKey": {"type": "string", "maxLength": 1000},
"secretKey": {"type": "string"},
"physicalBucket": {"type": "string", "maxLength": 255},
"region": {"type": "string", "maxLength": 120},
"endpoint": {"type": "string", "maxLength": 500},
"pathPrefix": {"type": "string", "maxLength": 500},
"cdnDomain": {"type": "string", "maxLength": 500},
"appId": {"type": "string", "maxLength": 255},
"useSsl": {"type": "boolean", "examples": [True]},
"usePathStyle": {"type": "boolean"},
"supportsPublicRead": {"type": "boolean", "examples": [True]},
"supportsPrivate": {"type": "boolean"},
},
"required": ["name", "provider", "status", "accessKey", "secretKey", "physicalBucket"],
},
"LightCoreStorageOriginCredentialReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageOriginDetailReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"LightCoreStorageOriginListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 120},
"provider": {"type": "string", "enum": ["alioss", "tencent_cos", "qiniu", "aws_s3", "minio"]},
"status": {"type": "string", "enum": ["active", "disabled"]},
"healthStatus": {"type": "string", "enum": ["unknown", "healthy", "unhealthy"]},
},
"required": ["pageNo", "pageSize"],
},
"LightCoreStorageOriginReplaceCredentialReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"credentialVersion": {"type": "integer", "minimum": 1},
"accessKey": {"type": "string", "maxLength": 1000},
"secretKey": {"type": "string"},
},
"required": ["id", "credentialVersion", "accessKey", "secretKey"],
},
"LightCoreStorageOriginStatusReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"status": {"type": "string", "enum": ["active", "disabled"]},
},
"required": ["id", "status"],
},
"LightCoreStorageOriginUpdateReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"name": {"type": "string", "maxLength": 120},
"status": {"type": "string", "enum": ["active", "disabled"]},
"physicalBucket": {"type": "string", "maxLength": 255},
"region": {"type": "string", "maxLength": 120},
"endpoint": {"type": "string", "maxLength": 500},
"pathPrefix": {"type": "string", "maxLength": 500},
"cdnDomain": {"type": "string", "maxLength": 500},
"appId": {"type": "string", "maxLength": 255},
"useSsl": {"type": "boolean", "examples": [True]},
"usePathStyle": {"type": "boolean"},
"supportsPublicRead": {"type": "boolean", "examples": [True]},
"supportsPrivate": {"type": "boolean"},
},
"required": ["id", "name", "status", "physicalBucket"],
},
"MoveToDirectoryReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
"directoryId": {"type": "integer"},
},
"required": ["id"],
},
"RenameFileReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
"newName": {"type": "string", "maxLength": 255},
},
"required": ["id", "newName"],
},
"RequestTraceDetailReq": {
"properties": {
"requestId": {"type": "string"},
},
"required": ["requestId"],
},
"RequestTraceListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "default": 20},
"requestId": {"type": "string"},
"channel": {"type": "string"},
"moduleKey": {"type": "string"},
"method": {"type": "string"},
"path": {"type": "string"},
"successStatus": {"type": "string", "enum": ["success", "fail"]},
"startTime": {"type": "string"},
"endTime": {"type": "string"},
},
"required": [],
},
"SSLCertificateAccountGetListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "maximum": 200, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"environment": {"type": "string", "enum": ["production", "staging"]},
"email": {"type": "string", "maxLength": 254, "format": "email"},
"status": {"type": "string", "enum": ["registering", "valid", "failed", "unknown"]},
},
"required": ["pageNo", "pageSize"],
},
"SSLCertificateAccountGetTermsReq": {
"properties": {
"environment": {"type": "string", "enum": ["production", "staging"]},
},
"required": ["environment"],
},
"SSLCertificateAccountRegisterReq": {
"properties": {
"environment": {"type": "string", "enum": ["production", "staging"]},
"email": {"type": "string", "maxLength": 254, "format": "email"},
"termsUrl": {"type": "string", "maxLength": 1024, "format": "uri"},
"acceptTerms": {"type": "boolean", "const": True},
},
"required": ["environment", "email", "termsUrl", "acceptTerms"],
},
"SSLCertificateRequestCreateReq": {
"properties": {
"name": {"type": "string", "maxLength": 120},
"accountId": {"type": "string", "format": "uuid"},
"domains": {"type": "array", "minItems": 1, "maxItems": 100, "items": {"type": "string", "maxLength": 253}},
"keyType": {"type": "string", "enum": ["rsa-2048", "ecdsa-p256"]},
},
"required": ["name", "accountId", "domains", "keyType"],
},
"SSLCertificateRequestDeleteReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
"version": {"type": "integer", "minimum": 1},
},
"required": ["id", "version"],
},
"SSLCertificateRequestGetListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "maximum": 200, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 200, "default": 20},
"keyword": {"type": "string", "maxLength": 120},
"environment": {"type": "string", "enum": ["production", "staging"]},
"accountId": {"type": "string", "format": "uuid"},
"domain": {"type": "string", "maxLength": 253},
"status": {"type": "string", "enum": ["ordering", "waiting_dns", "ready_to_issue", "validation_pending", "validating", "issuing", "issued", "failed", "unknown", "expired"]},
},
"required": ["pageNo", "pageSize"],
},
"SSLCertificateRequestIDReq": {
"properties": {
"id": {"type": "string", "format": "uuid"},
},
"required": ["id"],
},
"SystemHttpLogBatchDeleteReq": {
"properties": {
"ids": {"type": "array", "minItems": 1, "items": {"type": "integer"}},
},
"required": ["ids"],
},
"SystemHttpLogDeleteReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
},
"required": ["id"],
},
"SystemHttpLogDetailReq": {
"properties": {
"id": {"type": "integer"},
},
"required": [],
},
"SystemHttpLogListReq": {
"properties": {
"direction": {"type": "string", "enum": ["inbound", "outbound"]},
"source": {"type": "string"},
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "default": 20},
"method": {"type": "string"},
"requestUrl": {"type": "string"},
"responseStatus": {"type": "integer"},
"successStatus": {"type": "string", "enum": ["success", "fail"]},
"startTime": {"type": "string"},
"endTime": {"type": "string"},
},
"required": [],
},
"TableCheckReq": {
"properties": {
"module": {"type": "string"},
},
"required": [],
},
"TaskDetailReq": {
"properties": {
"id": {"type": "integer"},
},
"required": ["id"],
},
"TaskListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "maximum": 100, "default": 20},
},
"required": ["pageNo", "pageSize"],
},
"UpdatePasswordReq": {
"properties": {
"oldPassword": {"type": "string"},
"newPassword": {"type": "string"},
},
"required": ["oldPassword", "newPassword"],
},
"UploadFilesDeleteReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
},
"required": ["id"],
},
"UploadFilesDetailReq": {
"properties": {
"id": {"type": "integer", "minimum": 1},
},
"required": ["id"],
},
"UploadFilesListReq": {
"properties": {
"pageNo": {"type": "integer", "minimum": 1, "default": 1},
"pageSize": {"type": "integer", "minimum": 1, "default": 20},
"name": {"type": "string"},
"type": {"type": "string", "enum": ["image", "video", "file"]},
"directoryId": {"type": ["integer", "null"]},
},
"required": ["pageNo", "pageSize"],
},
"UploadFilesMultipart": {
"properties": {
"file": {"type": "string", "format": "binary"},
"businessCategory": {"type": "string", "default": "images"},
},
"required": ["file"],
},
}