API

nightshades

api

exception nightshades.api.UsageError(message='')[source]

An exception thrown when the API has been used improperly, typically a parent class.

nightshades.api.start_unit(user_id, seconds=1500, description=None)[source]

Start a unit for a given user with a default period of 25 minutes.

Parameters:
  • user_id (str or UUID) – a unique identifier for the user
  • seconds (int) – number of seconds in the new unit
  • description (str) – human-friendly description for the user of the unit
Returns:

Dict of new unit

Raises:
  • ValidationError – if the specified unit is less than 2 minutes
  • HasOngoingUnitAlready – if the user already has an ongoing unit
nightshades.api.mark_complete(unit_id, **kwargs)[source]

Mark a given unit as completed. This must be done within the expiry threshold of the unit’s expiry_time.

Parameters:unit_id (str or UUID) – the ID of the unit
Returns:True if a unit was updated
Return type:bool
nightshades.api.set_tags(unit_id, tag_csv, **kwargs)[source]

Replace the tags of a unit with a given string of comma-separated tags.

Raises:ValidationError – if more than 5 tags are given