"""
表订阅工具 (工具 32)
"""

from ._base import register_tool, ToolDef


@register_tool("toggle_table_subscription")
class ToggleTableSubscriptionTool(ToolDef):
    name = "toggle_table_subscription"
    description = "切换表的订阅状态"
    input_schema = {
        "type": "object",
        "properties": {
            "configId": {"type": "string", "description": "数据库配置 ID"},
            "tableName": {"type": "string", "description": "表名"},
            "isSubscribe": {"type": "boolean", "description": "true=订阅, false=取消订阅"},
        },
        "required": ["configId", "tableName", "isSubscribe"],
    }

    async def execute(self, args: dict) -> dict:
        return self.client.post("/api/datasource/subscription/toggle", json_data=args)
