datatypes.listings
#
- class tonita.datatypes.listings.AddSingleListingResult(success, error_message='')#
The outcome of adding/updating a single listing in a corpus.
- Parameters:
success (bool) –
True
if the operation succeeded.error_message (str) – An error message if
success
isFalse
. Empty ifsuccess
isTrue
.
- class tonita.datatypes.listings.AddListingsResponse(results)#
Response to a request to add/update a batch of listings in a corpus.
- Parameters:
results (Dict[str, AddSingleListingResult]) – Each key is a listing ID. The value denotes the outcome of attempting to add/update that listing.
- class tonita.datatypes.listings.State(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Gives the possible states of a listing.
- Parameters:
INACTIVE – The listing is inactive.
ACTIVE – The listing is active.
- class tonita.datatypes.listings.ListListingsResponse(results, next_listing_id=None)#
Response to a request to enumerate all listing IDs in a corpus.
- Parameters:
results (Dict[str, State]) – A dict mapping all listing ID’s for a particular corpus to their state, which will be one of the values given by the enum ListingState. Note that if the caller provides the
start_listing_id
orlimit
parameters in the request, then this dict will only contain a subset of all the listing IDs in the corpus. Specifically, it will only contain listing IDs that appear after (and including)start_listing_id
in lexicographical order. If thelimit
parameter is provided, the length of this dict is at mostlimit
.next_listing_id (Optional[str]) –
If the
limit
parameter is provided in the request and the number of listing IDs to return is greater thanlimit
, then this field will be set to the listing ID that comes immediately after the last element ofresults
, according to lexicographical order. This allows the caller to implement “pagination”.For example, the caller might pass
limit=1000
andstart_listing_id=None
in the first call. This will return inresults
the first 1000 listing IDs and store the 1001-st listing ID to return (suppose it’s “ajsdfl923”) in thisnext_listing_id
field. To page, the caller would then pass in a second calllimit=1000
andstart_listing_id="ajsdfl923"
. This would return the next 1000 listings, starting with “ajsdfl923”, and the ID of the 2001-st listing will be stored in thisnext_listing_id
field. If there are no more listings to “page” through after the currentresults
, this field will beNone
.
- class tonita.datatypes.listings.GetSingleListingResult(success, data, state, seconds_to_expiration, error_message)#
The outcome of retrieving a single listing for a corpus.
- Parameters:
success (bool) –
True
if this listing was successfully retrieved. This isFalse
if the listing does not exist for this corpus, or if there was an error in retrieving it.data (Optional[Dict[str, Any]]) – The raw data associated with this listing. This is the dict that was uploaded via
add()
. This isNone
ifsuccess
isFalse
.state (Optional[State]) – The state of this listing. The value must be one of the string values given by the enum ListingState. This is
None
ifsuccess
isFalse
.seconds_to_expiration (Optional[float]) – If inactive, the amount of time (in seconds) the corpus has left until it can no longer be recovered. This is None if success is
False
or ifstate
is not “INACTIVE”.error_message (str) – An error message if
success
isFalse
. Empty ifsuccess
isTrue
.
- class tonita.datatypes.listings.GetListingsResponse(results)#
Response to a request to retrieve a batch of listings for a corpus.
- Parameters:
results (Dict[str, GetSingleListingResult]) – Each key is a listing ID. The value contains the data associated with this listing, or error information about why it couldn’t be retrieved.
- class tonita.datatypes.listings.DeleteSingleListingResult(success, error_message)#
The outcome of deleting a single listing from a corpus.
- Parameters:
success (bool) –
True
if this listing was successfully deleted. This isFalse
if the listing does not already exist for this corpus, or if there was an error in deleting it.error_message (str) – An error message if
success
isFalse
. Empty ifsuccess
isTrue
.
- class tonita.datatypes.listings.DeleteListingsResponse(results)#
Response to a request to delete a batch of listings from a corpus.
- Parameters:
results (Dict[str, DeleteSingleListingResult]) – Each key is a listing ID. The value denotes the outcome of deleting this listing.
- class tonita.datatypes.listings.RecoverSingleListingResult(success, error_message)#
The outcome of recovering a single listing for a corpus.
- Parameters:
success (bool) – Whether this listing was successfully recovered. This is
False
if no such listing in the corpus is available to be recovered, if it’s active, or if there was an error in recovering it.error_message (str) – An error message if
success
isFalse
. Empty ifsuccess
isTrue
.
- class tonita.datatypes.listings.RecoverListingsResponse(results)#
Response to a request to recover a batch of listings for a corpus.
- Parameters:
results (Dict[str, RecoverSingleListingResult]) – Each key is a listing ID. The value denotes the outcome of recovering the corresponding listing.