Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4911f0ea

Přidáno uživatelem Matěj Zeman před asi 2 roky(ů)

re #9577 Api code documentation.

Zobrazit rozdíly:

server/sql_app/api/pcs.py
6 6

  
7 7
models.Base.metadata.create_all(bind=engine)
8 8

  
9
# prefix used for all endpoints in this file
9 10
pcs = APIRouter(prefix="/api/v1")
10 11

  
11 12

  
......
20 21

  
21 22
@pcs.post("/pc", response_model=schemas.PC)
22 23
def create_pc(pc: schemas.PCCreate, db: Session = Depends(get_db)):
24
    """
25
    Endpoint used for creating new pc
26
    """
23 27
    print(crud.create_pc(db=db, user=pc.username, host=pc.hostname))
24 28

  
25 29

  
26 30
@pcs.get("/pcs", response_model=List[schemas.PC])
27 31
def read_pcs(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
32
    """
33
    Returns all pcs currently saved in database
34
    """
28 35
    pcs = crud.get_pcs(db, skip=skip, limit=limit)
29 36
    return pcs
30 37

  
31 38

  
32 39
@pcs.get("/pc/{pc_id}", response_model=schemas.PC)
33 40
def read_pc(pc_id: int, db: Session = Depends(get_db)):
41
    """
42
    Returns one specific pc by given id
43
    """
34 44
    db_pc = crud.get_pc(db, pc_id=pc_id)
35 45
    if db_pc is None:
36 46
        raise HTTPException(status_code=404, detail="Device not found")

Také k dispozici: Unified diff