API Models

Defines models for all database entries and associated helpers.

Contains required attribute names and types for each model.

class models.Model

Parent (abstract) class for all database models which defines common helpers.

to_dict() Dict[str, Any]

Get a map of all properties for this model.

to_response() Dict[str, Any]

Convert this model to a JSON API response.

to_insert_str() str

Convert this model to a string which can be INSERTed into an SQL database.

abstract classmethod id_name() str

String name of the ID field for this model. For example, ‘item_id’ for items.

abstract classmethod id_length() int

Integer representing the expected length of the ID for this model.

abstract classmethod table_name() str

Table name in SQL database where entities for this model are stored.

class models.Item(item_id: Identifier, box_id: Identifier, mfg_part_number: str, quantity: int, description: str, digikey_part_number: str, mouser_part_number: str, jlcpcb_part_number: str, created_by: Identifier, created_epoch_millis: int)

Represents a single inventory item in the database.

class models.User(user_id: Identifier, api_key: str, name: str, authmask: int)

Represents a single user in the database.

class models.Reservation(reservation_id: Identifier, user_id: Identifier, item_id: Identifier, quantity: int)

Represents a single reservation in the database.

class models.Box(box_id: Identifier, name: str)

Represents a single inventory box (not inventory item container) in the database.

class identifier.Identifier(length: int = 32, id_: str | Identifier | None = None)