aito.api.modify

aito.api.modify(client: AitoClient, query: Dict | ModifyOperation | List[ModifyOperation], raise_for_status: bool | None = None, use_job: bool = False) ModifyResponse | RequestError

perform atomic modifications on table data using the Modify API

The modify endpoint allows individual modifications or a sequence of modifications in one atomic operation.

Can accept a raw query dict, a single ModifyOperation, or a list of ModifyOperations:

from aito.client.requests import Insert, Update, Delete

# Insert a single entry
api.modify(client, Insert("products", {"id": "1", "name": "Apple"}))

# Update entries matching a condition
api.modify(client, Update("products").where({"id": "1"}).set({"name": "New Name"}))

# Delete entries matching a condition
api.modify(client, Delete("products", {"id": "1"}))

# Multiple operations atomically
api.modify(client, [
    Insert("products", {"id": "1", "name": "Apple"}),
    Update("products").where({"id": "2"}).set({"name": "Banana"}),
    Delete("products", {"id": "3"})
])
Parameters:
  • client (AitoClient) – the AitoClient instance

  • query (Union[Dict, ModifyOperation, List[ModifyOperation]]) – the modify query - can be a Dict, a ModifyOperation (Insert/Update/Delete), or a list of ModifyOperations

  • raise_for_status (Optional[bool]) – raise RequestError if the request fails instead of returning the error If set to None, value from Client will be used. Defaults to None

  • use_job (bool) – use job fo request that takes longer than 30 seconds, defaults to False

Returns:

ModifyResponse or RequestError if an error occurred and not raise_for_status

Return type:

Union[ModifyResponse, RequestError]