generated from Luis/nextjs-python-web-template
attached
This commit is contained in:
@@ -175,6 +175,28 @@ async def attach(
|
||||
db: Session = Depends(sql_db.get_db),
|
||||
) -> dict[str, str]:
|
||||
background_tasks.add_task(
|
||||
sql_crud.check_health, db, entity_did, message="Not attched any more"
|
||||
attach_entity(entity_did, db), db, entity_did
|
||||
)
|
||||
return {"message": "Attaching in the background"}
|
||||
|
||||
# TODO
|
||||
def attach_entity(entity_did: str, db: Session) -> None:
|
||||
sql_crud.attach_entity_by_did(db, entity_did, True)
|
||||
while db_entity.attached:
|
||||
#query status endpoint
|
||||
#except not reached set false
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
@router.get("/api/v1/detach", response_model=Optional[Entity], tags=[Tags.entities])
|
||||
async def detach(
|
||||
background_tasks: BackgroundTasks,
|
||||
entity_did: str = "did:sov:test:1234",
|
||||
skip: int = 0,
|
||||
limit: int = 100,
|
||||
db: Session = Depends(sql_db.get_db),
|
||||
) -> dict[str, str]:
|
||||
background_tasks.add_task(
|
||||
sql_crud.set_attached_by_entity_did, db, entity_did, False
|
||||
)
|
||||
return {"message": "Detaching in the background"}
|
||||
Reference in New Issue
Block a user