База данных
SQLAlchemy модели и подключение к PostgreSQL + asyncpg.
Database Connection
- async infrastructure.database.database.init_models()[исходный код]
- Тип результата:
None
- async infrastructure.database.database.init_migrations()[исходный код]
- Тип результата:
None
- async infrastructure.database.database.get_db()[исходный код]
Models
- class infrastructure.database.models.DeviceModel(**kwargs)[исходный код]
Базовые классы:
Base- provision_config
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class infrastructure.database.models.ProvisionConfigModel(**kwargs)[исходный код]
Базовые классы:
Base- devices
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class infrastructure.database.models.UserModel(**kwargs)[исходный код]
Базовые классы:
Base- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class infrastructure.database.models.TicketModel(**kwargs)[исходный код]
Базовые классы:
Base- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
DeviceModel — таблица devices
ProvisionConfigModel — таблица provision_configs
Repositories
- class infrastructure.repositories.sql_device_repository.SQLDeviceRepository(db_session)[исходный код]
- Параметры:
db_session (AsyncSession) –
- __init__(db_session)[исходный код]
- Параметры:
db_session (AsyncSession) –
- Тип результата:
None
- async save(device)[исходный код]
Saves a Device entity to the repository.
- async delete(mac_address)[исходный код]
Deletes a Device entity from the repository by its MAC address.
- Параметры:
mac_address (MacAddress) –
- Тип результата:
- async get_by_mac(mac_address)[исходный код]
Retrieves a Device entity by its MAC address.
- Параметры:
mac_address (MacAddress) –
- Тип результата:
Device | None
- async update_last_activity(mac_address)[исходный код]
Updates the last activity timestamp of a Device entity.
- Параметры:
mac_address (MacAddress) –
- Тип результата:
Device | None
- async get_by_filters(ip_address=None, model=None, last_activity_from=None, last_activity_to=None, sort_by_last_activity=None, limit=None, offset=None)[исходный код]
Retrieves a list of Device entities matching the given filters.
- class infrastructure.repositories.sql_provision_repository.SQLProvisionRepository(db_session)[исходный код]
- Параметры:
db_session (AsyncSession) –
- __init__(db_session)[исходный код]
- Параметры:
db_session (AsyncSession) –
- Тип результата:
None
- async get_by_id(config_id)[исходный код]
Retrieves a ProvisionConfig entity by its ID.
- Параметры:
config_id (UUID) –
- Тип результата:
ProvisionConfig | None
- async get_by_device(device)[исходный код]
Retrieves a ProvisionConfig entity associated with a Device.
- Параметры:
device (Device) –
- Тип результата:
ProvisionConfig | None
- async get_default()[исходный код]
Retrieves the default ProvisionConfig entity.
- Тип результата:
- async save(config)[исходный код]
Saves a ProvisionConfig entity to the repository.
- Параметры:
config (ProvisionConfig) –
- Тип результата:
- async delete(config_id)[исходный код]
Deletes a ProvisionConfig entity by its ID.