# DO NOT EDIT — generated by _client_gen/convenience_emitter.py from convenience.json.
# Regenerate with: cd clients/v2 && python -c "from _client_gen.convenience_emitter import generate_convenience; generate_convenience()"

"""Ocr API namespace — generated from convenience.json."""

from __future__ import annotations

from typing import Any

from goodmem._api_base.ocr import OcrAPIBase, AsyncOcrAPIBase


# --- Convenience imports ---
from goodmem._overrides import (
    ocr_document_sync,
    ocr_document_async,
)
from goodmem.models.ocr_document_response import OcrDocumentResponse
from goodmem.models.ocr_input_format import OcrInputFormat


class OcrAPI(OcrAPIBase):
    def document(self, *, content: str | None = None, end_page: int | None = None, file_path: str | None = None, format: OcrInputFormat | None = None, include_markdown: bool | None = None, include_raw_json: bool | None = None, start_page: int | None = None) -> OcrDocumentResponse:
        """Run OCR on a document or image

        Runs layout-aware OCR on the provided document bytes and returns per-page results. When a page range is provided, only the inclusive subset is processed. Requires OCR_DOCUMENT permission.

        Args:
            content (str, optional): Base64-encoded document bytes. Mutually exclusive with `file_path`.
            end_page (int, optional): 0-based inclusive end page
            file_path (str, optional): Path to a local file to OCR. Mutually exclusive with `content`.
            format (OcrInputFormat, optional): Input format hint (AUTO, PDF, TIFF, PNG, JPEG, BMP)
            include_markdown (bool, optional): Include markdown rendering in the response
            include_raw_json (bool, optional): Include raw OCR JSON payload in the response
            start_page (int, optional): 0-based inclusive start page

        Returns:
            OcrDocumentResponse
        """
        _kw: dict[str, Any] = {}
        if content is not None: _kw["content"] = content
        if end_page is not None: _kw["end_page"] = end_page
        if file_path is not None: _kw["file_path"] = file_path
        if format is not None: _kw["format"] = format
        if include_markdown is not None: _kw["include_markdown"] = include_markdown
        if include_raw_json is not None: _kw["include_raw_json"] = include_raw_json
        if start_page is not None: _kw["start_page"] = start_page
        return ocr_document_sync(self, **_kw)



class AsyncOcrAPI(AsyncOcrAPIBase):
    async def document(self, *, content: str | None = None, end_page: int | None = None, file_path: str | None = None, format: OcrInputFormat | None = None, include_markdown: bool | None = None, include_raw_json: bool | None = None, start_page: int | None = None) -> OcrDocumentResponse:
        """Run OCR on a document or image

        Runs layout-aware OCR on the provided document bytes and returns per-page results. When a page range is provided, only the inclusive subset is processed. Requires OCR_DOCUMENT permission.

        Args:
            content (str, optional): Base64-encoded document bytes. Mutually exclusive with `file_path`.
            end_page (int, optional): 0-based inclusive end page
            file_path (str, optional): Path to a local file to OCR. Mutually exclusive with `content`.
            format (OcrInputFormat, optional): Input format hint (AUTO, PDF, TIFF, PNG, JPEG, BMP)
            include_markdown (bool, optional): Include markdown rendering in the response
            include_raw_json (bool, optional): Include raw OCR JSON payload in the response
            start_page (int, optional): 0-based inclusive start page

        Returns:
            OcrDocumentResponse
        """
        _kw: dict[str, Any] = {}
        if content is not None: _kw["content"] = content
        if end_page is not None: _kw["end_page"] = end_page
        if file_path is not None: _kw["file_path"] = file_path
        if format is not None: _kw["format"] = format
        if include_markdown is not None: _kw["include_markdown"] = include_markdown
        if include_raw_json is not None: _kw["include_raw_json"] = include_raw_json
        if start_page is not None: _kw["start_page"] = start_page
        return await ocr_document_async(self, **_kw)

