mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
fix(proxy_server.py): fix /key/update
endpoint to update key duration
also adds a test for this to our ci/cd
This commit is contained in:
parent
68a1fa36cf
commit
af2eabba91
2 changed files with 8 additions and 1 deletions
|
@ -4189,6 +4189,13 @@ async def update_key_fn(request: Request, data: UpdateKeyRequest):
|
|||
0,
|
||||
): # models default to [], spend defaults to 0, we should not reset these values
|
||||
non_default_values[k] = v
|
||||
|
||||
if "duration" in non_default_values:
|
||||
duration = non_default_values.pop("duration")
|
||||
duration_s = _duration_in_seconds(duration=duration)
|
||||
expires = datetime.utcnow() + timedelta(seconds=duration_s)
|
||||
non_default_values["expires"] = expires
|
||||
|
||||
response = await prisma_client.update_data(
|
||||
token=key, data={**non_default_values, "token": key}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue