diff --git a/docs/static/frigate-api.yaml b/docs/static/frigate-api.yaml index 1833aab99..56b31c9f8 100644 --- a/docs/static/frigate-api.yaml +++ b/docs/static/frigate-api.yaml @@ -172,76 +172,65 @@ paths: in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Cameras - name: labels in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Labels - name: zones in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Zones - name: reviewed in: query required: false schema: - anyOf: - - type: integer - - type: 'null' + type: integer default: 0 title: Reviewed - name: limit in: query required: false schema: - anyOf: - - type: integer - - type: 'null' + type: integer title: Limit - name: severity in: query required: false schema: - anyOf: - - type: string - - type: 'null' + allOf: + - $ref: '#/components/schemas/SeverityEnum' title: Severity - name: before in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: Before - name: after in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: After responses: '200': description: Successful Response content: application/json: - schema: { } + schema: + type: array + items: + $ref: '#/components/schemas/ReviewSegmentResponse' + title: Response Review Review Get '422': description: Validation Error content: @@ -259,36 +248,28 @@ paths: in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Cameras - name: labels in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Labels - name: zones in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Zones - name: timezone in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: utc title: Timezone responses: @@ -363,34 +344,26 @@ paths: in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Cameras - name: before in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: Before - name: after in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: After - name: scale in: query required: false schema: - anyOf: - - type: integer - - type: 'null' + type: integer default: 30 title: Scale responses: @@ -417,34 +390,26 @@ paths: in: query required: false schema: - anyOf: - - type: string - - type: 'null' + type: string default: all title: Cameras - name: before in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: Before - name: after in: query required: false schema: - anyOf: - - type: number - - type: 'null' + type: number title: After - name: scale in: query required: false schema: - anyOf: - - type: integer - - type: 'null' + type: integer default: 30 title: Scale responses: @@ -763,13 +728,25 @@ paths: content: application/json: schema: { } + /nvinfo: + get: + tags: + - App + summary: Nvinfo + operationId: nvinfo_nvinfo_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: { } /logs/{service}: get: tags: - App - Logs summary: Logs - description: Get logs for the requested service (frigate/nginx/go2rtc/chroma) + description: Get logs for the requested service (frigate/nginx/go2rtc) operationId: logs_logs__service__get parameters: - name: service @@ -781,7 +758,6 @@ paths: - frigate - nginx - go2rtc - - chroma title: Service - name: download in: query @@ -1042,7 +1018,8 @@ paths: - Preview summary: Preview Hour description: Get all mp4 previews relevant for time period given the timezone - operationId: preview_hour_preview__year_month___day___hour___camera_name___tz_name__get + operationId: >- + preview_hour_preview__year_month___day___hour___camera_name___tz_name__get parameters: - name: year_month in: path @@ -1092,7 +1069,8 @@ paths: - Preview summary: Get Preview Frames From Cache description: Get list of cached preview frames - operationId: get_preview_frames_from_cache_preview__camera_name__start__start_ts__end__end_ts__frames_get + operationId: >- + get_preview_frames_from_cache_preview__camera_name__start__start_ts__end__end_ts__frames_get parameters: - name: camera_name in: path @@ -1177,7 +1155,8 @@ paths: tags: - Export summary: Export Recording - operationId: export_recording_export__camera_name__start__start_time__end__end_time__post + operationId: >- + export_recording_export__camera_name__start__start_time__end__end_time__post parameters: - name: camera_name in: path @@ -1942,6 +1921,15 @@ paths: schema: type: string title: Event Id + - name: source + in: query + required: false + schema: + anyOf: + - $ref: '#/components/schemas/RegenerateDescriptionEnum' + - type: 'null' + default: thumbnails + title: Source responses: '200': description: Successful Response @@ -2029,12 +2017,12 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' - '{camera_name}': + /{camera_name}: get: tags: - Media summary: Mjpeg Feed - operationId: mjpeg_feed_camera_name__get + operationId: mjpeg_feed__camera_name__get parameters: - name: camera_name in: path @@ -2241,7 +2229,8 @@ paths: tags: - Media summary: Get Snapshot From Recording - operationId: get_snapshot_from_recording__camera_name__recordings__frame_time__snapshot__format__get + operationId: >- + get_snapshot_from_recording__camera_name__recordings__frame_time__snapshot__format__get parameters: - name: camera_name in: path @@ -2363,7 +2352,9 @@ paths: tags: - Media summary: Recordings - description: Return specific camera recordings between the given 'after'/'end' times. If not provided the last hour will be used + description: >- + Return specific camera recordings between the given 'after'/'end' times. + If not provided the last hour will be used operationId: recordings__camera_name__recordings_get parameters: - name: camera_name @@ -2377,14 +2368,14 @@ paths: required: false schema: type: number - default: 1727542549.303557 + default: 1728577904.036181 title: After - name: before in: query required: false schema: type: number - default: 1727546149.303926 + default: 1728581504.0362 title: Before responses: '200': @@ -3121,7 +3112,9 @@ paths: tags: - Media summary: Label Snapshot - description: Returns the snapshot image from the latest event for the given camera and label combo + description: >- + Returns the snapshot image from the latest event for the given camera + and label combo operationId: label_snapshot__camera_name___label__snapshot_jpg_get parameters: - name: camera_name @@ -3287,6 +3280,56 @@ components: title: Detail type: object title: HTTPValidationError + RegenerateDescriptionEnum: + type: string + enum: + - thumbnails + - snapshot + title: RegenerateDescriptionEnum + ReviewSegmentResponse: + properties: + id: + type: string + title: Id + camera: + type: string + title: Camera + start_time: + type: string + format: date-time + title: Start Time + end_time: + type: string + format: date-time + title: End Time + has_been_reviewed: + type: boolean + title: Has Been Reviewed + severity: + $ref: '#/components/schemas/SeverityEnum' + thumb_path: + type: string + title: Thumb Path + data: + title: Data + type: object + required: + - id + - camera + - start_time + - end_time + - has_been_reviewed + - severity + - thumb_path + - data + title: ReviewSegmentResponse + SeverityEnum: + type: string + enum: + - alert + - detection + - significant_motion + title: SeverityEnum SubmitPlusBody: properties: include_annotation: diff --git a/frigate/api/defs/review_query_parameters.py b/frigate/api/defs/review_query_parameters.py index a3f63d292..acc5eb2c9 100644 --- a/frigate/api/defs/review_query_parameters.py +++ b/frigate/api/defs/review_query_parameters.py @@ -1,28 +1,31 @@ -from typing import Optional +from typing import Union from pydantic import BaseModel +from pydantic.json_schema import SkipJsonSchema + +from frigate.api.defs.severity_enum import SeverityEnum class ReviewQueryParams(BaseModel): - cameras: Optional[str] = "all" - labels: Optional[str] = "all" - zones: Optional[str] = "all" - reviewed: Optional[int] = 0 - limit: Optional[int] = None - severity: Optional[str] = None - before: Optional[float] = None - after: Optional[float] = None + cameras: str = "all" + labels: str = "all" + zones: str = "all" + reviewed: int = 0 + limit: Union[int, SkipJsonSchema[None]] = None + severity: Union[SeverityEnum, SkipJsonSchema[None]] = None + before: Union[float, SkipJsonSchema[None]] = None + after: Union[float, SkipJsonSchema[None]] = None class ReviewSummaryQueryParams(BaseModel): - cameras: Optional[str] = "all" - labels: Optional[str] = "all" - zones: Optional[str] = "all" - timezone: Optional[str] = "utc" + cameras: str = "all" + labels: str = "all" + zones: str = "all" + timezone: str = "utc" class ReviewActivityMotionQueryParams(BaseModel): - cameras: Optional[str] = "all" - before: Optional[float] = None - after: Optional[float] = None - scale: Optional[int] = 30 + cameras: str = "all" + before: Union[float, SkipJsonSchema[None]] = None + after: Union[float, SkipJsonSchema[None]] = None + scale: int = 30 diff --git a/frigate/api/defs/review_responses.py b/frigate/api/defs/review_responses.py new file mode 100644 index 000000000..207a52860 --- /dev/null +++ b/frigate/api/defs/review_responses.py @@ -0,0 +1,16 @@ +from datetime import datetime + +from pydantic import BaseModel, Json + +from frigate.api.defs.severity_enum import SeverityEnum + + +class ReviewSegmentResponse(BaseModel): + id: str + camera: str + start_time: datetime + end_time: datetime + has_been_reviewed: bool + severity: SeverityEnum + thumb_path: str + data: Json diff --git a/frigate/api/defs/severity_enum.py b/frigate/api/defs/severity_enum.py new file mode 100644 index 000000000..c32b80018 --- /dev/null +++ b/frigate/api/defs/severity_enum.py @@ -0,0 +1,7 @@ +from enum import Enum + + +class SeverityEnum(str, Enum): + alert = "alert" + detection = "detection" + significant_motion = "significant_motion" diff --git a/frigate/api/fastapi_app.py b/frigate/api/fastapi_app.py index 3980e0b40..e3542458e 100644 --- a/frigate/api/fastapi_app.py +++ b/frigate/api/fastapi_app.py @@ -82,6 +82,10 @@ def create_fastapi_app( database.close() return response + @app.on_event("startup") + async def startup(): + logger.info("FastAPI started") + # Rate limiter (used for login endpoint) auth.rateLimiter.set_limit(frigate_config.auth.failed_login_rate_limit or "") app.state.limiter = limiter diff --git a/frigate/api/review.py b/frigate/api/review.py index 7c05386ef..ed3d041d8 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -17,6 +17,7 @@ from frigate.api.defs.review_query_parameters import ( ReviewQueryParams, ReviewSummaryQueryParams, ) +from frigate.api.defs.review_responses import ReviewSegmentResponse from frigate.api.defs.tags import Tags from frigate.models import Recordings, ReviewSegment from frigate.util.builtin import get_tz_modifiers @@ -26,7 +27,7 @@ logger = logging.getLogger(__name__) router = APIRouter(tags=[Tags.review]) -@router.get("/review") +@router.get("/review", response_model=list[ReviewSegmentResponse]) def review(params: ReviewQueryParams = Depends()): cameras = params.cameras labels = params.labels