Skip to content

Inventory

Runnable example

python/examples/inventory_manage.py — make a temp dir → copy → move → list, then clean up.

resoio.inventory.InventoryClient

InventoryClient(socket_path: str | None = None)

Bases: _BaseClient[InventoryStub]

Async, stateless client for the Resonite IO Inventory service.

Use as an async context manager so the gRPC channel closes deterministically. Socket resolution mirrors :class:resoio.ConnectionClient.

Source code in src/resoio/_client.py
def __init__(self, socket_path: str | None = None) -> None:
    # Defer resolution to __aenter__ so env vars patched between
    # construction and connection are honoured, and so resolution
    # errors surface at the connect site.
    self._explicit_path: str | None = socket_path
    self._channel: Channel | None = None
    self._stub: TStub | None = None
    self._resolved_path: str | None = None

list async

list(path: str) -> InventoryListing

List the entries directly under path (ls).

Source code in src/resoio/inventory.py
async def list(self, path: str) -> InventoryListing:
    """List the entries directly under ``path`` (``ls``)."""
    stub = self._require_stub()
    return _listing_from_proto(await stub.list(InventoryListRequest(path=path)))

mkdir async

mkdir(path: str) -> InventoryMutationResult

Create a folder at path (mkdir).

Source code in src/resoio/inventory.py
async def mkdir(self, path: str) -> InventoryMutationResult:
    """Create a folder at ``path`` (``mkdir``)."""
    stub = self._require_stub()
    return _mutation_from_proto(
        await stub.make_dir(InventoryMakeDirRequest(path=path))
    )

copy async

copy(src: str, dst: str, *, recursive: bool = False) -> InventoryMutationResult

Copy src to dst (cp); set recursive for folders (cp -r).

Source code in src/resoio/inventory.py
async def copy(
    self, src: str, dst: str, *, recursive: bool = False
) -> InventoryMutationResult:
    """Copy ``src`` to ``dst`` (``cp``); set ``recursive`` for folders
    (``cp -r``)."""
    stub = self._require_stub()
    return _mutation_from_proto(
        await stub.copy(
            InventoryCopyRequest(
                source_path=src, destination_path=dst, recursive=recursive
            )
        )
    )

move async

move(src: str, dst: str) -> InventoryMutationResult

Move src to dst (mv; folders move recursively).

Source code in src/resoio/inventory.py
async def move(self, src: str, dst: str) -> InventoryMutationResult:
    """Move ``src`` to ``dst`` (``mv``; folders move recursively)."""
    stub = self._require_stub()
    return _mutation_from_proto(
        await stub.move(InventoryMoveRequest(source_path=src, destination_path=dst))
    )

remove async

remove(path: str, *, recursive: bool = False) -> InventoryMutationResult

Remove path (rm); set recursive for folders (rm -r).

Source code in src/resoio/inventory.py
async def remove(
    self, path: str, *, recursive: bool = False
) -> InventoryMutationResult:
    """Remove ``path`` (``rm``); set ``recursive`` for folders (``rm
    -r``)."""
    stub = self._require_stub()
    return _mutation_from_proto(
        await stub.remove(InventoryRemoveRequest(path=path, recursive=recursive))
    )

spawn async

spawn(path: str) -> InventorySpawnResult

Spawn the item at path into the current world.

Source code in src/resoio/inventory.py
async def spawn(self, path: str) -> InventorySpawnResult:
    """Spawn the item at ``path`` into the current world."""
    stub = self._require_stub()
    return _spawn_from_proto(await stub.spawn(InventorySpawnRequest(path=path)))

fetch_thumbnail async

fetch_thumbnail(path: str) -> InventoryThumbnail

Fetch the thumbnail image of the item at path.

Resolves the item's Record.ThumbnailURI server-side and returns the raw image bytes plus their content type. Raises NotFound if the item does not exist or has no thumbnail.

Source code in src/resoio/inventory.py
async def fetch_thumbnail(self, path: str) -> InventoryThumbnail:
    """Fetch the thumbnail image of the item at ``path``.

    Resolves the item's ``Record.ThumbnailURI`` server-side and returns
    the raw image bytes plus their content type. Raises ``NotFound`` if
    the item does not exist or has no thumbnail.
    """
    stub = self._require_stub()
    return _thumbnail_from_proto(
        await stub.fetch_thumbnail(InventoryThumbnailRequest(path=path))
    )

resoio.inventory.InventoryListing dataclass

InventoryListing(path: str, entries: tuple[InventoryEntry, ...])

Contents of a directory returned by :meth:InventoryClient.list.

resoio.inventory.InventoryEntry dataclass

InventoryEntry(
    name: str,
    path: str,
    kind: InventoryEntryKind,
    record_id: str,
    asset_uri: str,
    is_public: bool,
    last_modified_unix_nanos: int,
)

One inventory entry (a folder or an item record).

ATTRIBUTE DESCRIPTION
record_id

Resonite cloud record id, empty for local-only entries.

TYPE: str

asset_uri

resdb:/// URI of the entry's primary asset, empty for folders.

TYPE: str

last_modified_unix_nanos

Last-modified time in UTC nanoseconds since the Unix epoch.

TYPE: int

resoio.inventory.InventoryEntryKind

Bases: Enum

Kind of an inventory entry (mirrors Resonite Record.RecordType).

resoio.inventory.InventoryMutationResult dataclass

InventoryMutationResult(path: str, record_id: str)

Result of a mutation (mkdir / cp / mv / rm).

resoio.inventory.InventorySpawnResult dataclass

InventorySpawnResult(source_path: str, spawned_slot_id: str, spawned_slot_name: str)

Result of spawning an item into the world.

resoio.inventory.InventoryThumbnail dataclass

InventoryThumbnail(data: bytes, content_type: str)

Thumbnail image of an inventory item.

ATTRIBUTE DESCRIPTION
data

Raw image bytes as stored on the Resonite CDN (typically WebP); returned verbatim, not re-encoded.

TYPE: bytes

content_type

MIME type of data (e.g. "image/webp"), empty if the server could not determine it.

TYPE: str