From 0f2be1cc1c10a3860fda2c41eb29022641a66010 Mon Sep 17 00:00:00 2001 From: mikatong Date: Thu, 26 Dec 2024 19:38:48 +0800 Subject: [PATCH] add crp schema --- schema/filter.json | 146 ++++++++++++++++++++++ schema/metadata.json | 289 +++++++++++++++++++++++++++++++++++++++++++ schema/schema.json | 174 ++++++++++++++++++++++++++ 3 files changed, 609 insertions(+) create mode 100644 schema/filter.json create mode 100644 schema/metadata.json create mode 100644 schema/schema.json diff --git a/schema/filter.json b/schema/filter.json new file mode 100644 index 0000000000..d26470cb55 --- /dev/null +++ b/schema/filter.json @@ -0,0 +1,146 @@ +{ + "provider_filter_schemas": { + "tencentcloudstack/tencentcloud": { + "tencentcloudstack/tencentcloud": { + "provider_filter": { + "block": {}, + "metadata": { + "attr_orders": [ + { + "name": "domain" + }, + { + "name": "profile" + }, + { + "name": "protocol" + }, + { + "name": "secret_id" + }, + { + "name": "secret_key" + }, + { + "name": "security_token" + }, + { + "name": "shared_credentials_dir" + } + ], + "display_name": "腾讯云资源" + } + }, + "resource_filters": { + "tencentcloud_dnspod_record": { + "block": { + "attributes": { + "domain": { + "type": "string", + "metadata": { + "filter": { + "enable": true, + "is_fixed": true + }, + "widget": "text", + "val_source": { + "values": {} + }, + "description": "域名.", + "display_name": "域名" + }, + "required": true, + "description": "域名." + }, + "sub_domain": { + "type": "string", + "metadata": { + "filter": { + "enable": true + }, + "widget": "text", + "val_source": { + "values": {} + }, + "description": "主机记录, 默认值为 @.", + "display_name": "主机记录" + }, + "optional": true, + "description": "主机记录, 默认值为 @." + }, + "is_exact_sub_domain": { + "type": "bool", + "metadata": { + "filter": { + "enable": true + }, + "values": [ + { + "value": true, + "display_name": "是" + } + ], + "widget": "select", + "val_source": { + "values": {} + }, + "description": "是否精确搜索主机记录", + "display_name": "是否精确搜索主机记录", + "default_value": { + "value": true, + "display_name": "是" + }, + "is_not_edited": true + }, + "required": true, + "description": "" + } + } + }, + "metadata": { + "order": 1, + "attr_orders": [ + { + "name": "domain" + }, + { + "name": "record_line" + }, + { + "name": "record_type" + }, + { + "name": "value" + }, + { + "name": "weight" + }, + { + "name": "mx" + }, + { + "name": "ttl" + }, + { + "name": "status" + }, + { + "name": "sub_domain" + }, + { + "name": "is_exact_sub_domain" + }, + { + "name": "remark" + } + ], + "display_name": "域名记录" + } + } + }, + "resources_display": "resources_display_flat", + "resources_optional": false + } + } + } +} \ No newline at end of file diff --git a/schema/metadata.json b/schema/metadata.json new file mode 100644 index 0000000000..b3e4ed7654 --- /dev/null +++ b/schema/metadata.json @@ -0,0 +1,289 @@ +{ + "provider_meta_schemas": { + "tencentcloudstack/tencentcloud": { + "provider_meta": { + "metadata": { + "display_name": "腾讯云资源", + "attr_orders": [ + { + "name": "domain" + }, + { + "name": "profile" + }, + { + "name": "protocol" + }, + { + "name": "secret_id" + }, + { + "name": "secret_key" + }, + { + "name": "security_token" + }, + { + "name": "shared_credentials_dir" + } + ] + }, + "block": { + "attributes": { + "domain": { + "display_name": "域名", + "widget": "text", + "is_public": true + }, + "profile": { + "display_name": "概述", + "widget": "text", + "is_public": true + }, + "protocol": { + "display_name": "协议", + "widget": "select", + "values": [ + { + "value": "HTTP", + "display_name": "HTTP", + "icon_url": "" + }, + { + "value": "HTTPS", + "display_name": "HTTPS", + "icon_url": "" + } + ], + "is_public": true + }, + "secret_id": { + "display_name": "secret_id", + "widget": "text", + "is_encrypt": true, + "is_public": true + }, + "secret_key": { + "display_name": "secret_key", + "widget": "text", + "is_encrypt": true, + "is_public": true + }, + "security_token": { + "display_name": "security_token", + "widget": "text", + "is_public": true + }, + "shared_credentials_dir": { + "display_name": "共享凭证目录", + "widget": "text", + "is_public": true + } + } + } + }, + "resource_metas": { + "tencentcloud_dnspod_record": { + "metadata": { + "display_name": "域名记录", + "order": 1, + "attr_orders": [ + { + "name": "domain" + }, + { + "name": "record_line" + }, + { + "name": "record_type" + }, + { + "name": "value" + }, + { + "name": "weight" + }, + { + "name": "mx" + }, + { + "name": "ttl" + }, + { + "name": "status" + }, + { + "name": "sub_domain" + }, + { + "name": "remark" + } + ] + }, + "block": { + "attributes": { + "domain": { + "display_name": "域名", + "widget": "text", + "filter": { + "enable": true, + "is_fixed": true + } + }, + "mx": { + "display_name": "MX 优先级", + "widget": "text", + "dependent_constraint": [ + { + "attr_name": "record_type", + "values": [ + { + "value": "TXT" + }, + { + "value": "A" + }, + { + "value": "CNAME" + } + ], + "fulfill_behavior": { + "visible": false + }, + "otherwise_behavior": { + "visible": true + } + } + ] + }, + "record_line": { + "display_name": "记录线路", + "val_source": { + "method": "GET", + "path": "/api/opx/rs/v1/namespaces/{namespace}/forward/domain-record?Domain={rely_resources[0]}&ProviderName=tencentcloudstack/tencentcloud&ResourceStackUid={resource_stack_uid}", + "values": { + "label_path": "$.Data.Lines[*]", + "value_path": "$.Data.Lines[*]" + }, + "rely_resources": [ + { + "name": "domain", + "source": "owner", + "required": true + } + ] + }, + "region_rule": { + "kind": "json_path", + "rule": "$.record_line" + }, + "widget": "select_remote", + "filter": { + "enable": true + } + }, + "record_type": { + "display_name": "记录类型", + "val_source": { + "method": "GET", + "path": "/api/opx/rs/v1/namespaces/{namespace}/forward/domain-record?Domain={rely_resources[0]}&ProviderName=tencentcloudstack/tencentcloud&ResourceStackUid={resource_stack_uid}", + "values": { + "label_path": "$.Data.Types[*]", + "value_path": "$.Data.Types[*]" + }, + "rely_resources": [ + { + "name": "domain", + "source": "owner", + "required": true + } + ] + }, + "widget": "select_remote", + "filter": { + "enable": true + } + }, + "remark": { + "display_name": "备注", + "widget": "text" + }, + "status": { + "display_name": "记录初始状态", + "widget": "select", + "values": [ + { + "value": "ENABLE", + "display_name": "ENABLE", + "icon_url": "" + }, + { + "value": "DISABLE", + "display_name": "DISABLE", + "icon_url": "" + } + ], + "filter": { + "enable": true + } + }, + "sub_domain": { + "display_name": "主机记录", + "widget": "text", + "filter": { + "enable": true + } + }, + "ttl": { + "display_name": "TTL", + "widget": "text", + "validator": { + "kind": "REGEX", + "rule": "^(604800|[1-5]?[0-9]{1,5}|[1-9])$" + } + }, + "value": { + "display_name": "记录值", + "widget": "text", + "filter": { + "enable": true + } + }, + "weight": { + "display_name": "权重信息", + "ref_variable_type": "opx_weight", + "widget": "text", + "filter": { + "enable": true + }, + "validator": { + "kind": "REGEX", + "rule": "^(100|[1-9]?[0-9])$" + }, + "dependent_constraint": [ + { + "attr_name": "record_type", + "values": [ + { + "value": "TXT" + }, + { + "value": "MX" + } + ], + "fulfill_behavior": { + "visible": false + }, + "otherwise_behavior": { + "visible": true + } + } + ] + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/schema/schema.json b/schema/schema.json new file mode 100644 index 0000000000..b6f4f451dc --- /dev/null +++ b/schema/schema.json @@ -0,0 +1,174 @@ +{ + "format_version": "1.0", + "provider_schemas": { + "tencentcloudstack/tencentcloud": { + "provider": { + "version": 0, + "block": { + "attributes": { + "domain": { + "type": "string", + "description": "API 请求的根域名, 默认为 'tencentcloudapi.com'.", + "description_kind": "plain", + "optional": true + }, + "profile": { + "type": "string", + "description": "在共享凭证中设置的配置文件名称, 也可以从 'TENCENTCLOUD_PROFILE' 环境变量中获取。如果未设置, 则使用通过 'tccli configure' 创建的默认配置文件.", + "description_kind": "plain", + "optional": true + }, + "protocol": { + "type": "string", + "description": "API 请求的协议, 有效值为 'HTTP' 和 'HTTPS'。默认为 'HTTPS'.", + "description_kind": "plain", + "optional": true + }, + "secret_id": { + "type": "string", + "description": "腾讯云访问密钥, 必须提供, 也可以从 'TENCENTCLOUD_SECRET_ID' 环境变量中获取.", + "description_kind": "plain", + "required": true + }, + "secret_key": { + "type": "string", + "description": "腾讯云密钥, 必须提供, 也可以从 'TENCENTCLOUD_SECRET_KEY' 环境变量中获取.", + "description_kind": "plain", + "required": true + }, + "security_token": { + "type": "string", + "description": "临时访问凭证的腾讯云安全令牌, 可以从 'TENCENTCLOUD_SECURITY_TOKEN' 环境变量中获取, 注意:对于支持的产品,请参考:临时密钥支持的产品(https://intl.cloud.tencent.com/document/product/598/10588).", + "description_kind": "plain", + "optional": true + }, + "shared_credentials_dir": { + "type": "string", + "description": "共享凭证的目录, 也可以从 'TENCENTCLOUD_SHARED_CREDENTIALS_DIR' 环境变量中获取, 如果未设置, 则默认为 ~/.tccli.", + "description_kind": "plain", + "optional": true + } + }, + "block_types": { + "assume_role": { + "nesting_mode": "set", + "block": { + "attributes": { + "policy": { + "type": "string", + "description": "在进行 AssumeRole 调用时使用的更严格的策略, 其内容不能包含 'principal' 元素, 注意:更多语法参考, 请参考:(https://intl.cloud.tencent.com/document/product/598/10603).", + "description_kind": "plain", + "optional": true + }, + "role_arn": { + "type": "string", + "description": "要扮演的角色的 ARN, 可以从 'TENCENTCLOUD_ASSUME_ROLE_ARN' 中获取.", + "description_kind": "plain", + "required": true + }, + "session_duration": { + "type": "number", + "description": "进行 AssumeRole 调用时的会话持续时间, 其值范围为 0 到 43200(秒), 默认为 7200 秒, 可以从 'TENCENTCLOUD_ASSUME_ROLE_SESSION_DURATION' 中获取.", + "description_kind": "plain", + "optional": true + }, + "session_name": { + "type": "string", + "description": "进行 AssumeRole 调用时要使用的会话名称, 可以从 'TENCENTCLOUD_ASSUME_ROLE_SESSION_NAME' 中获取.", + "description_kind": "plain", + "required": true + } + }, + "description": "'assume_role' 块, 如果提供, Terraform 将尝试使用提供的凭证扮演此角色.", + "description_kind": "plain" + }, + "max_items": 1 + } + }, + "description_kind": "plain" + } + }, + "resource_schemas": { + "tencentcloud_dnspod_record": { + "version": 0, + "block": { + "attributes": { + "domain": { + "type": "string", + "description": "域名.", + "description_kind": "plain", + "required": true + }, + "id": { + "type": "string", + "description_kind": "plain", + "computed": true + }, + "monitor_status": { + "type": "string", + "description": "记录的监控状态.", + "description_kind": "plain", + "computed": true + }, + "mx": { + "type": "number", + "description": "MX 优先级, 仅当记录类型为 MX 时有效, 范围为 1-20, 注意:当记录类型为 MX 时必须设置.", + "description_kind": "plain", + "optional": true + }, + "record_line": { + "type": "string", + "description": "记录线路, 依赖domain(域名), secret_id, secret_key.", + "description_kind": "plain", + "required": true + }, + "record_type": { + "type": "string", + "description": "记录类型, 依赖domain(域名), secret_id, secret_key.", + "description_kind": "plain", + "required": true + }, + "remark": { + "type": "string", + "description": "记录备注.", + "description_kind": "plain", + "optional": true + }, + "status": { + "type": "string", + "description": "记录的初始状态, 取值范围为 ENABLE 和 DISABLE, 默认为 ENABLE,如果传入 DISABLE, 则解析不会生效, 负载均衡的限制也不会被验证.", + "description_kind": "plain", + "optional": true + }, + "sub_domain": { + "type": "string", + "description": "主机记录, 默认值为 '@'.", + "description_kind": "plain", + "required": true + }, + "ttl": { + "type": "number", + "description": "TTL, 范围为 1-604800, 不同级别的域名最小值不同, 默认为 600.", + "description_kind": "plain", + "optional": true + }, + "value": { + "type": "string", + "description": "记录值.", + "description_kind": "plain", + "required": true + }, + "weight": { + "type": "number", + "description": "权重信息, 取值范围为 0-100, 仅适用于企业 VIP 域名, 0 表示关闭, 不传该参数表示未设置权重信息, 默认为 0.", + "description_kind": "plain", + "optional": true + } + }, + "description_kind": "plain" + } + } + } + } + } +} \ No newline at end of file