Fix plus api (#13937)

* Fix plus api

* Fix regenerate api
This commit is contained in:
Nicolas Mowen 2024-09-24 11:22:11 -06:00 committed by GitHub
parent a9ff795948
commit 7854e1c2c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -28,3 +28,7 @@ class EventsCreateBody(BaseModel):
class EventsEndBody(BaseModel): class EventsEndBody(BaseModel):
end_time: Optional[int] = datetime.now().timestamp() end_time: Optional[int] = datetime.now().timestamp()
class SubmitPlusBody(BaseModel):
include_annotation: int = Field(default=1)

View File

@ -22,6 +22,7 @@ from frigate.api.defs.events_body import (
EventsDescriptionBody, EventsDescriptionBody,
EventsEndBody, EventsEndBody,
EventsSubLabelBody, EventsSubLabelBody,
SubmitPlusBody,
) )
from frigate.api.defs.events_query_parameters import ( from frigate.api.defs.events_query_parameters import (
DEFAULT_TIME_RANGE, DEFAULT_TIME_RANGE,
@ -616,7 +617,7 @@ def set_retain(event_id: str):
@router.post("/events/{event_id}/plus") @router.post("/events/{event_id}/plus")
def send_to_plus(request: Request, event_id: str): def send_to_plus(request: Request, event_id: str, body: SubmitPlusBody = None):
if not request.app.frigate_config.plus_api.is_active(): if not request.app.frigate_config.plus_api.is_active():
message = "PLUS_API_KEY environment variable is not set" message = "PLUS_API_KEY environment variable is not set"
logger.error(message) logger.error(message)
@ -630,9 +631,7 @@ def send_to_plus(request: Request, event_id: str):
status_code=400, status_code=400,
) )
include_annotation = ( include_annotation = body.include_annotation if body is not None else None
request.json.get("include_annotation") if request.is_json else None
)
try: try:
event = Event.get(Event.id == event_id) event = Event.get(Event.id == event_id)
@ -945,7 +944,7 @@ def set_description(
) )
@router.put("/events/<id>/description/regenerate") @router.put("/events/{event_id}/description/regenerate")
def regenerate_description(request: Request, event_id: str): def regenerate_description(request: Request, event_id: str):
try: try:
event: Event = Event.get(Event.id == event_id) event: Event = Event.get(Event.id == event_id)