Get a specific tool configuration by tool kit name and key. Args: toolkit_name (str): The name of the tool kit. key (str): The key of the tool configuration. organisation (Organisation): The organization associated with the user. Returns: ToolConfig: Th
(toolkit_name: str, key: str, organisation: Organisation = Depends(get_user_organisation))
| 153 | |
| 154 | @router.get("/get/toolkit/{toolkit_name}/key/{key}", status_code=200) |
| 155 | def get_tool_config(toolkit_name: str, key: str, organisation: Organisation = Depends(get_user_organisation)): |
| 156 | """ |
| 157 | Get a specific tool configuration by tool kit name and key. |
| 158 | |
| 159 | Args: |
| 160 | toolkit_name (str): The name of the tool kit. |
| 161 | key (str): The key of the tool configuration. |
| 162 | organisation (Organisation): The organization associated with the user. |
| 163 | |
| 164 | Returns: |
| 165 | ToolConfig: The tool configuration with the specified key. |
| 166 | |
| 167 | Raises: |
| 168 | HTTPException (status_code=403): If the user is not authorized to access the tool kit. |
| 169 | HTTPException (status_code=404): If the specified tool kit or tool configuration is not found. |
| 170 | """ |
| 171 | |
| 172 | user_toolkits = db.session.query(Toolkit).filter(Toolkit.organisation_id == organisation.id).all() |
| 173 | |
| 174 | toolkit = db.session.query(Toolkit).filter_by(name=toolkit_name) |
| 175 | if toolkit not in user_toolkits: |
| 176 | raise HTTPException(status_code=403, detail='Unauthorized') |
| 177 | |
| 178 | tool_config = db.session.query(ToolConfig).filter( |
| 179 | ToolConfig.toolkit_id == toolkit.id, |
| 180 | ToolConfig.key == key |
| 181 | ).first() |
| 182 | if not tool_config: |
| 183 | raise HTTPException(status_code=404, detail="Tool configuration not found") |
| 184 | if(is_encrypted(tool_config.value)): |
| 185 | tool_config.value = decrypt_data(tool_config.value) |
| 186 | if tool_config.key_type == ToolConfigKeyType.FILE.value: |
| 187 | tool_config.value = json.loads(tool_config.value) |
| 188 | |
| 189 | return tool_config |
nothing calls this directly
no test coverage detected