API

class aiosnow.models.table.TableModel(client: aiosnow.client.Client, attachment: bool = True, **kwargs)[source]
create(payload: dict) → aiosnow.request.response.Response

Create a new record

Parameters:payload – New record payload
Returns:Response
delete(selection: Union[aiosnow.query.condition.Condition, str]) → aiosnow.request.response.Response

Delete matching record

Parameters:selection – Condition or ID
Returns:Response
download_file(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str], dst_dir: str = '.') → aiosnow.models.attachment.file.FileHandler[source]

Download incident attachment

Parameters:
  • selection – Attachment selection
  • dst_dir – Destination directory
Returns:

FileHandler object

get(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str] = None, **kwargs) → aiosnow.request.response.Response

Buffered many

Fetch and store the entire result in memory.

Note: It’s recommended to use the stream method when dealing with a large number of records.

Keyword Arguments:
 
  • selection – Aiosnow-compatible query
  • limit (int) – Maximum number of records to return
  • offset (int) – Starting record index
Returns:

Response

get_attachment(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str] = None, **kwargs) → aiosnow.request.response.Response[source]

Returns Response if the given condition yielded exactly one attachment

Parameters:
  • selection – Attachment selection
  • **kwargs – arguments to pass along to AttachmentModel
Returns:

Response object

get_attachments(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str] = None, **kwargs) → aiosnow.request.response.Response[source]

Returns list of attachments for this table

Parameters:
  • selection – Attachment selection
  • **kwargs – arguments to pass along to AttachmentModel
Returns:

Response object

get_object_id(value: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str]) → str

Get object id by str or Condition

Immediately return if value is of str type.

Parameters:value – Condition or str
Returns:Object id
get_one(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str] = None, **kwargs) → aiosnow.request.response.Response

Get one record

Parameters:selection – aiosnow-compatible query
Returns:Response
stream(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str] = None, **kwargs) → AsyncGenerator[T_co, T_contra]

Stream-like async generator

Chunk size determines the number of records to fetch in one go. Setting a lower chunk size decreases memory usage, but increases the number of requests sent to the server.

Keyword Arguments:
 
  • selection – aiosnow-compatible query
  • limit (int) – Maximum number of records to return
  • offset (int) – Starting record index
  • page_size (int) – Number of records to fetch in one go
Yields:

Chunk of records

update(selection: Union[aiosnow.query.condition.Condition, str], payload: dict) → aiosnow.request.response.Response

Update matching record

Parameters:
  • selection – Condition or ID of object to update
  • payload – Update payload
Returns:

Response

upload_file(selection: Union[aiosnow.query.selector.Selector, aiosnow.query.condition.Condition, str], path: str) → aiosnow.request.response.Response[source]

Upload incident attachment

Parameters:
  • selection – Attachment selection
  • path – Source file path
Returns:

Response