feat(17-01): add CredentialProfile model and Pydantic schemas
- SQLAlchemy model mapping to credential_profiles table (migration 037) - CredentialProfileCreate with model_validator enforcing per-type required fields - CredentialProfileUpdate with conditional validation on type change - CredentialProfileResponse without any credential fields (write-only) - Device model updated with credential_profile_id FK and relationship Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,6 +117,17 @@ class Device(Base):
|
||||
sector: Mapped["Sector"] = relationship( # type: ignore[name-defined]
|
||||
"Sector", back_populates="devices", foreign_keys=[sector_id]
|
||||
)
|
||||
credential_profile_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
UUID(as_uuid=True),
|
||||
ForeignKey("credential_profiles.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
credential_profile: Mapped["CredentialProfile"] = relationship( # type: ignore[name-defined]
|
||||
"CredentialProfile",
|
||||
back_populates="devices",
|
||||
foreign_keys=[credential_profile_id],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Device id={self.id} hostname={self.hostname!r} tenant_id={self.tenant_id}>"
|
||||
|
||||
Reference in New Issue
Block a user