Skip to content

Commit

Permalink
refactor user credentials model and introduce variable and secret model
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Dec 18, 2024
1 parent b24a9e9 commit dfef678
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11616,7 +11616,7 @@ class UserCredentials(Base):
reference: Mapped[str] = mapped_column(nullable=False)
source_type: Mapped[str] = mapped_column(nullable=False)
source_id: Mapped[str] = mapped_column(nullable=False)
current_group_id: Mapped[int] = mapped_column(ForeignKey("user_credentials_group.id"), index=True)
current_group_id: Mapped[int] = mapped_column(ForeignKey("user_credentials_group.id"), index=True, nullable=True)
create_time: Mapped[Optional[datetime]] = mapped_column(default=now)
update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now)

Expand All @@ -11630,29 +11630,45 @@ class CredentialsGroup(Base):

id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(nullable=False)
user_credentials_id: Mapped[int] = mapped_column(ForeignKey("user_credentials.id"), index=True, nullable=True)
user_credentials_id: Mapped[int] = mapped_column(ForeignKey("user_credentials.id"), index=True)
create_time: Mapped[Optional[datetime]] = mapped_column(default=now)
update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now)


class Credential(Base):
class Variable(Base):
"""
Represents a credential associated with a user for a specific service.
Represents a variable associated with a user for a specific service.
"""

__tablename__ = "credential"
__tablename__ = "variable"

id: Mapped[int] = mapped_column(primary_key=True)
user_credential_group_id: Mapped[int] = mapped_column(
ForeignKey("user_credentials_group.id"), index=True, nullable=False
)
name: Mapped[str] = mapped_column(nullable=False)
type: Mapped[str] = mapped_column(nullable=False)
value: Mapped[str] = mapped_column(nullable=False)
create_time: Mapped[Optional[datetime]] = mapped_column(default=now)
update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now)


class Secret(Base):
"""
Represents a secret associated with a user for a specific service.
"""

__tablename__ = "secret"

id: Mapped[int] = mapped_column(primary_key=True)
user_credential_group_id: Mapped[int] = mapped_column(
ForeignKey("user_credentials_group.id"), index=True, nullable=False
)
name: Mapped[str] = mapped_column(nullable=False)
already_set: Mapped[bool] = mapped_column(nullable=False, default=False)
create_time: Mapped[Optional[datetime]] = mapped_column(default=now)
update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now)


# The following models (HDA, LDDA) are mapped imperatively (for details see discussion in PR #12064)
# TLDR: there are issues ('metadata' property, Galaxy object wrapping) that need to be addressed separately
# before these models can be mapped declaratively. Keeping them in the mapping module breaks the auth package
Expand Down

0 comments on commit dfef678

Please sign in to comment.