Skip to content

pixano.app.routers.items

create_item(dataset_id, id, item, settings) async

Add an item in the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
id str

ID of the item.

required
item ItemModel

Item to add.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required

Returns:

Type Description
ItemModel

The item added.

Source code in pixano/app/routers/items.py
@router.post("/{dataset_id}/{id}", response_model=ItemModel)
async def create_item(
    dataset_id: str,
    id: str,
    item: ItemModel,
    settings: Annotated[Settings, Depends(get_settings)],
) -> ItemModel:
    """Add an item in the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        id: ID of the item.
        item: Item to add.
        settings: App settings.

    Returns:
        The item added.
    """
    return await create_row_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, id, item, settings)

create_items(dataset_id, items, settings) async

Add items in the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
items list[ItemModel]

Items to add.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required

Returns:

Type Description
list[ItemModel]

List of items added.

Source code in pixano/app/routers/items.py
@router.post("/{dataset_id}/", response_model=list[ItemModel])
async def create_items(
    dataset_id: str,
    items: list[ItemModel],
    settings: Annotated[Settings, Depends(get_settings)],
) -> list[ItemModel]:
    """Add items in the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        items: Items to add.
        settings: App settings.

    Returns:
        List of items added.
    """
    return await create_rows_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, items, settings)

delete_item(dataset_id, id, settings) async

Delete an item from the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
id str

ID of the item to delete.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required
Source code in pixano/app/routers/items.py
@router.delete("/{dataset_id}/{id}")
async def delete_item(dataset_id: str, id: str, settings: Annotated[Settings, Depends(get_settings)]) -> None:
    """Delete an item from the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        id: ID of the item to delete.
        settings: App settings.
    """
    return await delete_row_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, id, settings)

delete_items(dataset_id, ids, settings) async

Delete items from the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
ids Annotated[list[str], Query()]

IDs of the items to delete.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required
Source code in pixano/app/routers/items.py
@router.delete("/{dataset_id}/")
async def delete_items(
    dataset_id: str,
    ids: Annotated[list[str], Query()],
    settings: Annotated[Settings, Depends(get_settings)],
) -> None:
    """Delete items from the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        ids: IDs of the items to delete.
        settings: App settings.
    """
    return await delete_rows_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, ids, settings)

get_item(dataset_id, id, settings) async

Get an item from the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
id str

ID of the item.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required

Returns:

Type Description
ItemModel

The item.

Source code in pixano/app/routers/items.py
@router.get("/{dataset_id}/{id}", response_model=ItemModel)
async def get_item(dataset_id: str, id: str, settings: Annotated[Settings, Depends(get_settings)]) -> ItemModel:
    """Get an item from the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        id: ID of the item.
        settings: App settings.

    Returns:
        The item.
    """
    return await get_row_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, id, settings)

get_items(dataset_id, settings, ids=Query(None), limit=None, skip=0, where=None) async

Get sources from the 'item' table of a dataset.

They can be filtered by IDs, a where clause or paginated.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required
ids list[str] | None

IDs of the sources.

Query(None)
limit int | None

Limit number of sources.

None
skip int

Skip number of sources.

0
where str | None

Where clause.

None

Returns:

Type Description
list[ItemModel]

List of sources.

Source code in pixano/app/routers/items.py
@router.get("/{dataset_id}/", response_model=list[ItemModel])
async def get_items(
    dataset_id: str,
    settings: Annotated[Settings, Depends(get_settings)],
    ids: list[str] | None = Query(None),
    limit: int | None = None,
    skip: int = 0,
    where: str | None = None,
) -> list[ItemModel]:
    """Get sources from the `'item'` table of a dataset.

    They can be filtered by IDs, a where clause or paginated.

    Args:
        dataset_id: Dataset ID containing the table.
        settings: App settings.
        ids: IDs of the sources.
        limit: Limit number of sources.
        skip: Skip number of sources.
        where: Where clause.

    Returns:
        List of sources.
    """
    return await get_rows_handler(
        dataset_id=dataset_id,
        group=SchemaGroup.ITEM,
        table=SchemaGroup.ITEM.value,
        settings=settings,
        where=where,
        ids=ids,
        item_ids=None,
        limit=limit,
        skip=skip,
    )

update_item(dataset_id, id, item, settings) async

Update an item in the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
id str

ID of the item.

required
item ItemModel

Item to update.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required

Returns:

Type Description
ItemModel

The item updated.

Source code in pixano/app/routers/items.py
@router.put("/{dataset_id}/{id}", response_model=ItemModel)
async def update_item(
    dataset_id: str,
    id: str,
    item: ItemModel,
    settings: Annotated[Settings, Depends(get_settings)],
) -> ItemModel:
    """Update an item in the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        id: ID of the item.
        item: Item to update.
        settings: App settings.

    Returns:
        The item updated.
    """
    return await update_row_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, id, item, settings)

update_items(dataset_id, items, settings) async

Update items in the 'item' table of a dataset.

Parameters:

Name Type Description Default
dataset_id str

Dataset ID containing the table.

required
items list[ItemModel]

Items to update.

required
settings Annotated[Settings, Depends(get_settings)]

App settings.

required

Returns:

Type Description
list[ItemModel]

List of items updated.

Source code in pixano/app/routers/items.py
@router.put("/{dataset_id}/", response_model=list[ItemModel])
async def update_items(
    dataset_id: str,
    items: list[ItemModel],
    settings: Annotated[Settings, Depends(get_settings)],
) -> list[ItemModel]:
    """Update items in the `'item'` table of a dataset.

    Args:
        dataset_id: Dataset ID containing the table.
        items: Items to update.
        settings: App settings.

    Returns:
        List of items updated.
    """
    return await update_rows_handler(dataset_id, SchemaGroup.ITEM, SchemaGroup.ITEM.value, items, settings)