| 273 | |
| 274 | |
| 275 | class GithubInstallation(Base): |
| 276 | __tablename__: str = "github_installation" |
| 277 | |
| 278 | installation_id: Mapped[int] = mapped_column(primary_key=True) |
| 279 | _token: Mapped[str | None] = mapped_column("token", String(2048), nullable=True) |
| 280 | token_expires_at: Mapped[datetime | None] = mapped_column(nullable=True) |
| 281 | status: Mapped[str] = mapped_column( |
| 282 | SQLAEnum("active", "deleted", "suspended", name="github_installation_status"), |
| 283 | nullable=False, |
| 284 | default="active", |
| 285 | ) |
| 286 | |
| 287 | # Relationships |
| 288 | projects: Mapped[list["Project"]] = relationship( |
| 289 | back_populates="github_installation" |
| 290 | ) |
| 291 | |
| 292 | @property |
| 293 | def token(self) -> str | None: |
| 294 | if self._token is None: |
| 295 | return None |
| 296 | fernet = get_fernet() |
| 297 | return fernet.decrypt(self._token.encode()).decode() |
| 298 | |
| 299 | @token.setter |
| 300 | def token(self, value: str): |
| 301 | if not value: |
| 302 | self._token = None |
| 303 | else: |
| 304 | fernet = get_fernet() |
| 305 | self._token = fernet.encrypt(value.encode()).decode() |
| 306 | |
| 307 | @override |
| 308 | def __repr__(self): |
| 309 | return f"<GithubInstallation {self.installation_id}>" |
| 310 | |
| 311 | |
| 312 | class Project(Base): |
no outgoing calls
no test coverage detected