generated from Luis/nextjs-python-web-template
Georg-Stahn-georgs (#25)
Co-authored-by: sara-pervana <saramakishti@gmail.com> Co-authored-by: ui-asset-bot <ui-asset-bot@gchq.icu> Co-authored-by: Onur Arslan <runoxa@hotmail.com> Co-authored-by: Arslan, Erdem <erdem.arslan@valtech.com> Co-authored-by: Luis-Hebendanz <consulting@qube.email> Reviewed-on: #25 Co-authored-by: Georg-Stahn <g.stahn@campus.tu-berlin.de> Co-committed-by: Georg-Stahn <g.stahn@campus.tu-berlin.de>
This commit was merged in pull request #25.
This commit is contained in:
54
pkgs/clan-cli/clan_cli/webui/api_outputs.py
Normal file
54
pkgs/clan-cli/clan_cli/webui/api_outputs.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class Status(Enum):
|
||||
ONLINE = "online"
|
||||
OFFLINE = "offline"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
class Machine(BaseModel):
|
||||
name: str
|
||||
status: Status
|
||||
|
||||
|
||||
class RepositoryBase(BaseModel):
|
||||
title: str
|
||||
description: str | None = None
|
||||
|
||||
|
||||
class RepositoryCreate(RepositoryBase):
|
||||
pass
|
||||
|
||||
|
||||
class Repository(RepositoryBase):
|
||||
id: int
|
||||
prod_id: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class ProducerBase(BaseModel):
|
||||
id: int
|
||||
|
||||
|
||||
class ProducerCreate(ProducerBase):
|
||||
jsonblob: int = Field(
|
||||
42,
|
||||
title="The Json",
|
||||
description="this is the value of json",
|
||||
gt=30,
|
||||
lt=50,
|
||||
list=[1, 2, "3"],
|
||||
)
|
||||
|
||||
|
||||
class Producer(ProducerBase):
|
||||
id: int
|
||||
repos: list[Repository] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@@ -101,7 +101,7 @@ class EntityCreate(EntityBase):
|
||||
class Entity(EntityCreate):
|
||||
producers: List[Producer] = []
|
||||
consumers: List[Consumer] = []
|
||||
repository: Optional[Repository] = None
|
||||
repository: List[Repository] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
Binary file not shown.
@@ -1,8 +1,9 @@
|
||||
from typing import Generator
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
# from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import Session, declarative_base, sessionmaker
|
||||
|
||||
URL = "sqlite:///./sql_app.db"
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ class Entity(Base):
|
||||
## Relations ##
|
||||
producers = relationship("Producer", back_populates="entity")
|
||||
consumers = relationship("Consumer", back_populates="entity")
|
||||
repository = relationship("Repository", uselist=False, back_populates="entity")
|
||||
repository = relationship("Repository", back_populates="entity")
|
||||
# TODO maby refactor to repositories
|
||||
|
||||
|
||||
class ProducerAbstract(Base):
|
||||
|
||||
Reference in New Issue
Block a user