| 65 | |
| 66 | |
| 67 | class Action(ModelEntity): |
| 68 | action_id: str |
| 69 | |
| 70 | name: str |
| 71 | operation_id: str |
| 72 | description: str |
| 73 | url: str |
| 74 | method: ActionMethod |
| 75 | path_param_schema: Optional[Dict[str, ActionParam]] |
| 76 | query_param_schema: Optional[Dict[str, ActionParam]] |
| 77 | body_type: ActionBodyType |
| 78 | body_param_schema: Optional[Dict[str, ActionParam]] |
| 79 | |
| 80 | # function definition for LLM function call |
| 81 | function_def: ChatCompletionFunction |
| 82 | |
| 83 | openapi_schema: Dict |
| 84 | authentication: ActionAuthentication |
| 85 | |
| 86 | updated_timestamp: int |
| 87 | created_timestamp: int |
| 88 | |
| 89 | @staticmethod |
| 90 | def build(row): |
| 91 | authentication_dict = load_json_attr(row, "authentication", default_value={}) |
| 92 | if authentication_dict: |
| 93 | authentication = ActionAuthentication(**authentication_dict) |
| 94 | authentication.decrypt() |
| 95 | else: |
| 96 | authentication = ActionAuthentication(type=ActionAuthenticationType.none).model_dump() |
| 97 | |
| 98 | method = row["method"] |
| 99 | if not method: |
| 100 | method = ActionMethod.NONE |
| 101 | |
| 102 | body_type = row["body_type"] |
| 103 | if not body_type: |
| 104 | body_type = ActionBodyType.NONE |
| 105 | |
| 106 | return Action( |
| 107 | action_id=row["action_id"], |
| 108 | name=row["name"], |
| 109 | operation_id=row["operation_id"], |
| 110 | description=row["description"], |
| 111 | url=row["url"], |
| 112 | method=method, |
| 113 | path_param_schema=load_json_attr(row, "path_param_schema", None), |
| 114 | query_param_schema=load_json_attr(row, "query_param_schema", None), |
| 115 | body_param_schema=load_json_attr(row, "body_param_schema", None), |
| 116 | body_type=body_type, |
| 117 | function_def=load_json_attr(row, "function_def", {}), |
| 118 | openapi_schema=load_json_attr(row, "openapi_schema", {}), |
| 119 | authentication=authentication, |
| 120 | updated_timestamp=row["updated_timestamp"], |
| 121 | created_timestamp=row["created_timestamp"], |
| 122 | ) |
| 123 | |
| 124 | def to_response_dict(self) -> Dict: |