generated from Luis/nextjs-python-web-template
push first sql setup try
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
|
from ..api_outputs import Machine, Status
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@router.get("/health", include_in_schema=True)
|
@router.get("/health", include_in_schema=True)
|
||||||
async def health() -> str:
|
async def health() -> Machine: #str:
|
||||||
return "OK"
|
return Machine(name="test", status=Status.ONLINE)
|
||||||
|
# return "OK"
|
||||||
|
|||||||
0
pkgs/clan-cli/clan_cli/webui/sql_db.py
Normal file
0
pkgs/clan-cli/clan_cli/webui/sql_db.py
Normal file
25
pkgs/clan-cli/clan_cli/webui/sql_models.py
Normal file
25
pkgs/clan-cli/clan_cli/webui/sql_models.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from .sql_db import Base
|
||||||
|
|
||||||
|
class Repository(Base):
|
||||||
|
__tablename__ = "repositories"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
service_name = Column(String, unique=True, index=True)
|
||||||
|
service_type = Column(String, unique=True, index=True)
|
||||||
|
end_point = Column(String, unique=True, index=True)
|
||||||
|
producer = Column(String)
|
||||||
|
producer_did = Column(String)
|
||||||
|
network = Column(String)
|
||||||
|
|
||||||
|
class Producer(Base):
|
||||||
|
__tablename__ = "producers"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
service_name = Column(String, unique=True, index=True)
|
||||||
|
service_type = Column(String, unique=True, index=True)
|
||||||
|
end_point = Column(String, unique=True, index=True)
|
||||||
|
usage = Column(String) # TODO enum?
|
||||||
|
status = Column(String)
|
||||||
|
action = Column(String)
|
||||||
41
pkgs/clan-cli/clan_cli/webui/sql_schemas.py
Normal file
41
pkgs/clan-cli/clan_cli/webui/sql_schemas.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class ProducerBase(BaseModel):
|
||||||
|
title: str
|
||||||
|
description: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class ProducerCreate(ProducerBase):
|
||||||
|
service_name: str
|
||||||
|
service_type: str
|
||||||
|
end_point: str
|
||||||
|
usage_str: str
|
||||||
|
status: str
|
||||||
|
action: str
|
||||||
|
|
||||||
|
|
||||||
|
class Producer(ProducerBase):
|
||||||
|
id: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
|
||||||
|
|
||||||
|
class RepositoryBase(BaseModel):
|
||||||
|
service_name: str
|
||||||
|
|
||||||
|
|
||||||
|
class RepositoryCreate(RepositoryBase):
|
||||||
|
service_type: str
|
||||||
|
end_point: str
|
||||||
|
producer_did: str
|
||||||
|
network: str
|
||||||
|
|
||||||
|
|
||||||
|
class Repository(RepositoryBase):
|
||||||
|
id: int
|
||||||
|
Producers: list[Producer] = []
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
Reference in New Issue
Block a user