added lease update request (PUT)

This commit is contained in:
Oscar Krause 2022-12-19 13:15:19 +01:00
parent 0db526a2d6
commit 16e4fc4158

View File

@ -18,6 +18,8 @@ from helper import load_key, private_bytes, public_key
app = FastAPI()
LEASE_EXPIRE_DELTA = relativedelta(minutes=15) # days=90
URL = '192.168.178.196'
SITE_KEY_FILE = load_key('/opt/fastapi-dls/site.key')
SITE_KEY_XID = '00000000-0000-0000-0000-000000000000'
@ -216,7 +218,7 @@ async def lessor(request: Request):
"lease": {
"ref": scope_ref,
"created": cur_time,
"expires": cur_time + relativedelta(minutes=15), # days=90
"expires": cur_time + LEASE_EXPIRE_DELTA,
"recommended_lease_renewal": 0.15,
"offline_lease": "true",
"license_type": "CONCURRENT_COUNTED_SINGLE"
@ -250,6 +252,25 @@ async def lease(request: Request):
return response
# venv/lib/python3.9/site-packages/nls_core_lease/lease_single.py
@app.put('/leasing/v1/lease/{lease_ref}')
async def lease_renew(request: Request, lease_ref: str):
print('> renew')
cur_time = datetime.utcnow()
response = {
"lease_ref": lease_ref,
"expires": cur_time + LEASE_EXPIRE_DELTA,
"recommended_lease_renewal": 0.16,
"offline_lease": True,
"prompts": None,
"sync_timestamp": cur_time
}
return response
@app.delete('/leasing/v1/lessor/leases')
async def lease_remove(request: Request, status_code=200):
cur_time = datetime.utcnow()