Skip to content

paths

paths #

Request models for the CaptureGraph captured-data file API.

Pydantic models the server and its clients (capturegraph-sync, the iOS client) exchange. A single-file transfer addresses its leaf in the URL and carries metadata in headers, so the models here are the batch request shapes plus the caller profile every request stamps into its headers:

  • [LeafResolveRequest][] / [LeafResolveEntry][] — POST files:resolve, a batch of (path, cached version) leaves answered positionally by LeafResolveResponse.
  • [FileSaveRequest][] / [FileSaveEntry][] — POST files:save, many small files uploaded inline in one round trip, answered by FileSaveResponse.
  • [RequestProfileModel][] / [LocationModel][] — the caller's identity and opted-in position, carried in X-CG-* headers (see headers.py).

Each path is the chain of on-disk folder names from the target root, its last component the leaf stem (no extension); the server resolves it against the target's declared schema. See docs/dsl/captured-data-format.md for the spec.

FileSaveEntry #

Bases: BaseModel

One small file in a batch save request.

path addresses the leaf (last component is its stem); extension is the bytes' actual on-disk extension (must be one the leaf's scalar declares); and data_base64 carries the bytes themselves. The batch is for many tiny files — a larger file uses a single streaming PUT files/{path} instead.

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class FileSaveEntry(BaseModel):
    """One small file in a batch save request.

    ``path`` addresses the leaf (last component is its stem); ``extension`` is the
    bytes' actual on-disk extension (must be one the leaf's scalar declares); and
    ``data_base64`` carries the bytes themselves. The batch is for many tiny files
    — a larger file uses a single streaming ``PUT files/{path}`` instead.
    """

    path: list[str]
    extension: str
    data_base64: str

FileSaveRequest #

Bases: BaseModel

Request body for the files:save batch endpoint.

Every entry is validated against the schema before anything is written, so the batch either applies in full or fails with no partial write.

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class FileSaveRequest(BaseModel):
    """Request body for the ``files:save`` batch endpoint.

    Every entry is validated against the schema before anything is written, so
    the batch either applies in full or fails with no partial write.
    """

    entries: list[FileSaveEntry]

LeafResolveEntry #

Bases: BaseModel

One leaf in a batch resolve request.

path is the chain of on-disk folder names to the leaf, its last component the leaf stem. known_version is the content version the client currently has cached, or None when it holds no copy; the server compares it against the leaf's current version to decide unchanged vs present.

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class LeafResolveEntry(BaseModel):
    """One leaf in a batch resolve request.

    ``path`` is the chain of on-disk folder names to the leaf, its last component
    the leaf stem. ``known_version`` is the content version the client currently
    has cached, or ``None`` when it holds no copy; the server compares it against
    the leaf's current version to decide ``unchanged`` vs ``present``.
    """

    path: list[str]
    known_version: str | None = None

LeafResolveRequest #

Bases: BaseModel

Request body for the files:resolve batch endpoint.

results[i] of the response corresponds to entries[i].

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class LeafResolveRequest(BaseModel):
    """Request body for the ``files:resolve`` batch endpoint.

    ``results[i]`` of the response corresponds to ``entries[i]``.
    """

    entries: list[LeafResolveEntry]

LocationModel #

Bases: BaseModel

A geographic position carried as request context.

The WGS84 fields of the edu.cornell.location value (altitude_meters/heading_degrees default to 0.0), declared in the X-CG-Location header's field order. A plain mirror so [api_models][] stays decoupled from the type system; the server converts it to a cg.Location at the interceptor boundary.

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class LocationModel(BaseModel):
    """A geographic position carried as request context.

    The WGS84 fields of the ``edu.cornell.location`` value
    (``altitude_meters``/``heading_degrees`` default to ``0.0``), declared in
    the ``X-CG-Location`` header's field order. A plain mirror so
    [api_models][] stays decoupled from the type system; the server converts
    it to a ``cg.Location`` at the interceptor boundary.
    """

    latitude: float
    longitude: float
    altitude_meters: float = 0.0
    heading_degrees: float = 0.0

RequestProfileModel #

Bases: BaseModel

Who (and optionally where) a request comes from.

user_id is the requesting client's identity so interceptor-backed leaves can resolve per-user; location is the caller's position when they have opted in to sharing it with this server. Built server-side from the request's X-CG-User-Id / X-CG-Location headers; both absent by default.

Source code in capturegraph-lib/capturegraph/api_models/paths.py
class RequestProfileModel(BaseModel):
    """Who (and optionally where) a request comes from.

    ``user_id`` is the requesting client's identity so interceptor-backed leaves
    can resolve per-user; ``location`` is the caller's position when they have
    opted in to sharing it with this server. Built server-side from the request's
    ``X-CG-User-Id`` / ``X-CG-Location`` headers; both absent by default.
    """

    user_id: str | None = None
    location: LocationModel | None = None