转换为字典
(self, include_password: bool = False)
| 374 | updated_at = Column(DateTime, default=utcnow_naive, onupdate=utcnow_naive) |
| 375 | |
| 376 | def to_dict(self, include_password: bool = False) -> Dict[str, Any]: |
| 377 | """转换为字典""" |
| 378 | result = { |
| 379 | 'id': self.id, |
| 380 | 'name': self.name, |
| 381 | 'type': self.type, |
| 382 | 'host': self.host, |
| 383 | 'port': self.port, |
| 384 | 'username': self.username, |
| 385 | 'enabled': self.enabled, |
| 386 | 'is_default': self.is_default or False, |
| 387 | 'priority': self.priority, |
| 388 | 'last_used': self.last_used.isoformat() if self.last_used else None, |
| 389 | 'created_at': self.created_at.isoformat() if self.created_at else None, |
| 390 | 'updated_at': self.updated_at.isoformat() if self.updated_at else None, |
| 391 | } |
| 392 | if include_password: |
| 393 | result['password'] = self.password |
| 394 | else: |
| 395 | result['has_password'] = bool(self.password) |
| 396 | return result |
| 397 | |
| 398 | @property |
| 399 | def proxy_url(self) -> str: |
no outgoing calls
no test coverage detected