Update labels for a specific tool. Replaces all existing labels. Args: tool_id: Tool ID to update tenant_id: Tenant ID for access control labels: New list of label strings user_id: User performing the update Returns: True if updated, False if to
(tool_id: int, tenant_id: str, labels: List[str], user_id: str)
| 159 | |
| 160 | |
| 161 | def update_tool_labels(tool_id: int, tenant_id: str, labels: List[str], user_id: str) -> bool: |
| 162 | """ |
| 163 | Update labels for a specific tool. Replaces all existing labels. |
| 164 | |
| 165 | Args: |
| 166 | tool_id: Tool ID to update |
| 167 | tenant_id: Tenant ID for access control |
| 168 | labels: New list of label strings |
| 169 | user_id: User performing the update |
| 170 | |
| 171 | Returns: |
| 172 | True if updated, False if tool not found or access denied |
| 173 | """ |
| 174 | with get_db_session() as session: |
| 175 | tool = session.query(ToolInfo).filter( |
| 176 | ToolInfo.tool_id == tool_id, |
| 177 | ToolInfo.author == tenant_id, |
| 178 | ToolInfo.delete_flag != 'Y' |
| 179 | ).first() |
| 180 | if not tool: |
| 181 | return False |
| 182 | tool.labels = labels |
| 183 | tool.updated_by = user_id |
| 184 | session.flush() |
| 185 | return True |
| 186 | |
| 187 | |
| 188 | def query_all_enabled_tool_instances(agent_id: int, tenant_id: str, version_no: int = 0): |