(self)
| 1803 | return ResourceMappingSerializer().get_resource_count(result) |
| 1804 | |
| 1805 | def get_tools(self): |
| 1806 | self.is_valid(raise_exception=True) |
| 1807 | |
| 1808 | workspace_manage = is_workspace_manage_permission_read(self.data.get("user_id"), |
| 1809 | self.data.get("workspace_id"), 'TOOL:READ') |
| 1810 | is_x_pack_ee = self.is_x_pack_ee() |
| 1811 | results = native_search( |
| 1812 | self.get_query_set(workspace_manage, is_x_pack_ee), |
| 1813 | get_file_content( |
| 1814 | os.path.join( |
| 1815 | PROJECT_DIR, |
| 1816 | "apps", |
| 1817 | "tools", |
| 1818 | "sql", |
| 1819 | "list_tool.sql" |
| 1820 | if workspace_manage |
| 1821 | else ("list_tool_user_ee.sql" if is_x_pack_ee else "list_tool_user.sql"), |
| 1822 | ) |
| 1823 | ), |
| 1824 | ) |
| 1825 | |
| 1826 | # 返回包含文件夹和工具的结构 |
| 1827 | return { |
| 1828 | "folders": [folder for folder in results if folder["resource_type"] == "folder"], |
| 1829 | "tools": [ |
| 1830 | { |
| 1831 | **tool, |
| 1832 | "input_field_list": json.loads(tool.get("input_field_list", "[]")), |
| 1833 | "init_field_list": json.loads(tool.get("init_field_list", "[]")), |
| 1834 | } |
| 1835 | for tool in results |
| 1836 | if tool["resource_type"] == "tool" |
| 1837 | ], |
| 1838 | } |
nothing calls this directly
no test coverage detected