tonita.listings#

tonita.listings.add(data=None, json_path=None, corpus_id=None, api_key=None, session=None)#

Add (or overwrite if already exists) data for a batch of listings.

Parameters:
  • data (Optional[Dict[str, Any]]) – A dict containing listings data. Exactly one of data or json_path should be provided.

  • json_path (Optional[str]) –

    This path can either point to a JSON file or to a directory containing JSON files.

    Specifically, if this path points to a directory, all files in the directory (and its subdirectories) with file extension “.json” will be assumed to be in valid JSON format and will be uploaded. Files without the “.json” extension will be skipped. If a JSON file could not be sent to the server for any reason, a warning will be logged to the console.

    A relative path will be resolved to an absolute one.

    Exactly one of data or json_path should be provided.

  • corpus_id (Optional[str]) – The ID of the corpus this listing belongs to. If this argument is None, then the value of tonita.corpus_id will be used.

  • api_key (Optional[str]) – An API key. If this argument is None, then the value of tonita.api_key will be used.

  • session (Optional[requests.Session]) – A requests.Session object to use for the request. If the user does not provide a session, a new one will be created.

Returns:

See docstring for AddListingsResponse.

Return type:

AddListingsResponse

Raises:
tonita.listings.list(start_listing_id=None, limit=1000, corpus_id=None, api_key=None)#

List IDs of all listings in corpus given by corpus_id.

Parameters:
  • start_listing_id (Optional[str]) – If provided, then only listings whose IDs appear at or after this listing ID according to lexicographical order are returned. If None, then listing IDs are returned beginning with the first listing ID according to lexicographical order.

  • limit (int) – If provided, then at most this many listing IDs are returned (in lexicographical order). The default returns at most 1000 listing IDs. To return all listing IDs in the corpus, pass -1. If there are more listing IDs to return than a positive limit, then the next_listing_id field in the return object will be populated with the next listing ID according to lexicographical order. The caller can pass this listing ID as start_listing_id in a subsequent call to list() to “page” through the remaining results. If there are no more listing IDs to return, the next_listing_id field in the response will be None.

  • corpus_id (Optional[str]) – The ID of the corpus this listing belongs to. If this argument is None, then the value of tonita.corpus_id will be used.

  • api_key (Optional[str]) – An API key. If this argument is None, then the value of tonita.api_key will be used.

Returns:

See docstring for ListListingsResponse.

Return type:

ListListingsResponse

Raises:
tonita.listings.get(listing_ids, corpus_id=None, api_key=None)#

Retrieve data for specified listings.

Parameters:
  • listing_ids (List[str]) – The IDs of the listings to retrieve. The elements of this list must be distinct (i.e., no duplicates); a TonitaBadRequestError will be raised otherwise.

  • corpus_id (Optional[str]) – The ID of the corpus this listing belongs to. If this argument is None, then the value of tonita.corpus_id will be used.

  • api_key (Optional[str]) – An API key. If this argument is None, then the value of tonita.api_key will be used.

Returns:

See docstring for GetListingsResponse.

Return type:

GetListingsResponse

Raises:
tonita.listings.delete(listing_ids, corpus_id=None, api_key=None)#

Delete data for listings.

Parameters:
  • listing_ids (List[str]) – The IDs of the listings to delete. The elements of this list must be distinct (i.e., no duplicates); a TonitaBadRequestError will be raised otherwise.

  • corpus_id (Optional[str]) – The ID of the corpus this listing belongs to. If this argument is None, then the value of tonita.corpus_id will be used.

  • api_key (Optional[str]) – An API key. If this argument is None, then the value of tonita.api_key will be used.

Returns:

See docstring for DeleteListingsResponse.

Return type:

DeleteListingsResponse

Raises:
tonita.listings.recover(listing_ids, corpus_id=None, api_key=None)#

Recover a batch of listings that were previously marked to be deleted.

Parameters:
  • listing_ids (List[str]) – The IDs of the listings to recover. The elements of this list must be distinct (i.e., no duplicates); a TonitaBadRequestError will be raised otherwise.

  • corpus_id (Optional[str]) – The ID of the corpus this listing belongs to. If this argument is None, then the value of tonita.corpus_id will be used.

  • api_key (Optional[str]) – An API key. If this argument is None, then the value of tonita.api_key will be used.

Returns:

See docstring for RecoverListingsResponse.

Return type:

RecoverListingsResponse

Raises: