Skip to content

capturegraph.api_models.responses #

CaptureGraph API Response Models#

Pydantic models for API responses from the CaptureGraph server. These models are shared between capturegraph-server and capturegraph-sync.

FileHashResponse #

Bases: BaseModel

Response from the load/file/hash endpoint.

The server returns either: - file_data_base64: For small files, the complete file data - file_hash_base64: For large files, a hash for comparison - file_missing: True if the file doesn't exist - file_extension: The actual file extension on the server (without dot)

Source code in capturegraph-lib/capturegraph/api_models/responses.py
class FileHashResponse(BaseModel):
    """Response from the load/file/hash endpoint.

    The server returns either:
    - file_data_base64: For small files, the complete file data
    - file_hash_base64: For large files, a hash for comparison
    - file_missing: True if the file doesn't exist
    - file_extension: The actual file extension on the server (without dot)
    """

    file_data_base64: str | None = None
    file_hash_base64: str | None = None
    file_missing: bool = False
    file_extension: str | None = None

    def get_identifier(self) -> str | None:
        """Get a unique identifier for this file's current state.

        Only returns an identifier for large files (where server provides a hash).
        For small files (where data is returned directly), returns None so the
        file is always re-downloaded - this is fine since the data is already
        included in the hash response anyway.
        """
        if self.file_missing:
            return None

        # Only use hash for large files - small files will always re-download
        return self.file_hash_base64

get_identifier() #

Get a unique identifier for this file's current state.

Only returns an identifier for large files (where server provides a hash). For small files (where data is returned directly), returns None so the file is always re-downloaded - this is fine since the data is already included in the hash response anyway.

Source code in capturegraph-lib/capturegraph/api_models/responses.py
def get_identifier(self) -> str | None:
    """Get a unique identifier for this file's current state.

    Only returns an identifier for large files (where server provides a hash).
    For small files (where data is returned directly), returns None so the
    file is always re-downloaded - this is fine since the data is already
    included in the hash response anyway.
    """
    if self.file_missing:
        return None

    # Only use hash for large files - small files will always re-download
    return self.file_hash_base64

SessionIDsResponse #

Bases: BaseModel

Response from the load/session_ids endpoint.

Source code in capturegraph-lib/capturegraph/api_models/responses.py
class SessionIDsResponse(BaseModel):
    """Response from the load/session_ids endpoint."""

    session_ids: list[int] | None = None

TargetsResponse #

Bases: BaseModel

Response listing available targets on the server.

Source code in capturegraph-lib/capturegraph/api_models/responses.py
class TargetsResponse(BaseModel):
    """Response listing available targets on the server."""

    targets: list[str]

FileIndicesResponse #

Bases: BaseModel

Response from the load/file/indices endpoint.

Source code in capturegraph-lib/capturegraph/api_models/responses.py
class FileIndicesResponse(BaseModel):
    """Response from the load/file/indices endpoint."""

    indices: list[int] | None = None