MCPcopy Create free account
hub / github.com/digitalinnovationone/workout_api / patch

Function patch

workout_api/atleta/controller.py:104–122  ·  view source on GitHub ↗
(id: UUID4, db_session: DatabaseDependency, atleta_up: AtletaUpdate = Body(...))

Source from the content-addressed store, hash-verified

102 response_model=AtletaOut,
103)
104async def patch(id: UUID4, db_session: DatabaseDependency, atleta_up: AtletaUpdate = Body(...)) -> AtletaOut:
105 atleta: AtletaOut = (
106 await db_session.execute(select(AtletaModel).filter_by(id=id))
107 ).scalars().first()
108
109 if not atleta:
110 raise HTTPException(
111 status_code=status.HTTP_404_NOT_FOUND,
112 detail=f'Atleta não encontrado no id: {id}'
113 )
114
115 atleta_update = atleta_up.model_dump(exclude_unset=True)
116 for key, value in atleta_update.items():
117 setattr(atleta, key, value)
118
119 await db_session.commit()
120 await db_session.refresh(atleta)
121
122 return atleta
123
124
125@router.delete(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected