eventit_py.pydantic_events module

class eventit_py.pydantic_events.BaseCountableEvent(*, user: str | None = None, group: str | None = None, function_name: str | None = None, event_location: str | None = None, description: str | None = None, uuid: UUID = None, timestamp: AwareDatetime = None, time_window: int = 15, count: int = 1)

Represents a countable event with a time window and number of events.

time_window

Time window in seconds.

Type:

int

count

Number of events in the time window.

Type:

int

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'count': FieldInfo(annotation=int, required=False, default=1, description='Number of events in the time window'), 'description': FieldInfo(annotation=Union[str, NoneType], required=False, metadata=[Strict(strict=True)]), 'event_location': FieldInfo(annotation=Union[str, NoneType], required=False), 'function_name': FieldInfo(annotation=Union[str, NoneType], required=False), 'group': FieldInfo(annotation=Union[str, NoneType], required=False), 'time_window': FieldInfo(annotation=int, required=False, default=15, description='Time window in seconds'), 'timestamp': FieldInfo(annotation=AwareDatetime, required=False, default_factory=_handle_timestamp), 'user': FieldInfo(annotation=Union[str, NoneType], required=False), 'uuid': FieldInfo(annotation=UUID, required=False, default_factory=uuid4, metadata=[UuidVersion(uuid_version=4)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class eventit_py.pydantic_events.BaseEvent(*, user: str | None = None, group: str | None = None, function_name: str | None = None, event_location: str | None = None, description: str | None = None, uuid: UUID = None, timestamp: AwareDatetime = None)

Base class to be used for event tracking. Can be specialized for specific applications (Flask, Django, add custom data fields, etc)

Timestamp and UUID fields are always present, and automatically generated

Parameters:
  • user (Optional[str]) – The user associated with the event.

  • group (Optional[str]) – The group associated with the event.

  • function_name (Optional[str]) – The name of the function associated with the event.

  • event_location (Optional[str]) – The location of the event.

  • description (Optional[str]) – The description of the event.

  • uuid (UUID4) – The UUID of the event.

  • timestamp (AwareDatetime) – The timestamp of the event in UTC timezone. Uses millisecond accuracy

Functions:

ensure_utc_timezone(value: datetime.datetime): A field validator method to ensure the timestamp is in UTC timezone. serialize_uuid(value: UUID4, _info): A field serializer method to serialize the UUID value. __repr__(): Returns a string representation of the BaseEvent object. __str__(): Returns a string representation of the BaseEvent object using the model_dump_json() method.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=False, metadata=[Strict(strict=True)]), 'event_location': FieldInfo(annotation=Union[str, NoneType], required=False), 'function_name': FieldInfo(annotation=Union[str, NoneType], required=False), 'group': FieldInfo(annotation=Union[str, NoneType], required=False), 'timestamp': FieldInfo(annotation=AwareDatetime, required=False, default_factory=_handle_timestamp), 'user': FieldInfo(annotation=Union[str, NoneType], required=False), 'uuid': FieldInfo(annotation=UUID, required=False, default_factory=uuid4, metadata=[UuidVersion(uuid_version=4)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.