mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2024-11-23 23:41:06 +03:00
implemented endpoint for expired origins (origins without active leases)
This commit is contained in:
parent
d25921dbb0
commit
87a79815dd
12
app/main.py
12
app/main.py
@ -196,7 +196,13 @@ async def _origins_delete(request: Request):
|
||||
return Response(status_code=201)
|
||||
|
||||
|
||||
@app.delete('/-/origins/{origin_ref}', summary='* Origins')
|
||||
@app.delete('/-/origins/expired', summary='* Delete all Origins without active Lease')
|
||||
async def _origins_delete_expired(request: Request):
|
||||
Origin.delete_expired(db)
|
||||
return Response(status_code=201)
|
||||
|
||||
|
||||
@app.delete('/-/origins/{origin_ref}', summary='* Delete specific Origin')
|
||||
async def _origins_delete_origin_ref(request: Request, origin_ref: str):
|
||||
if Origin.delete(db, [origin_ref]) == 1:
|
||||
return Response(status_code=201)
|
||||
@ -219,13 +225,13 @@ async def _leases(request: Request, origin: bool = False):
|
||||
return JSONr(response)
|
||||
|
||||
|
||||
@app.delete('/-/leases/expired', summary='* Leases')
|
||||
@app.delete('/-/leases/expired', summary='* Delete all expired Leases')
|
||||
async def _lease_delete_expired(request: Request):
|
||||
Lease.delete_expired(db)
|
||||
return Response(status_code=201)
|
||||
|
||||
|
||||
@app.delete('/-/lease/{lease_ref}', summary='* Lease')
|
||||
@app.delete('/-/lease/{lease_ref}', summary='* Delete specific Lease')
|
||||
async def _lease_delete(request: Request, lease_ref: str):
|
||||
if Lease.delete(db, lease_ref) == 1:
|
||||
return Response(status_code=201)
|
||||
|
@ -116,6 +116,12 @@ async function deleteOrigin(origin_ref) {
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
async function deleteExpiredOrigins() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("DELETE", `/-/origins/expired`, true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
async function deleteLease(lease_ref) {
|
||||
if (lease_ref === undefined)
|
||||
lease_ref = window.prompt("Please enter 'lease_ref' which should be deleted");
|
||||
|
@ -13,6 +13,9 @@
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteOrigin().finally(() => load())">
|
||||
delete origin
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteExpiredOrigins().finally(() => load())">
|
||||
delete all expired origins
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteOriginsWrapper()">
|
||||
delete all
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user