device-manager.app.api.dal#

Device data access layer.

Functions#

dal_create_device(→ api.db.Device)

Add a new device to the database.

dal_get_device(→ api.db.Device | None)

Fetch a device from database.

dal_get_all_devices(→ list[api.db.Device])

Get a list of all existing devices.

dal_delete_device(→ bool)

Delete a device by identifier.

dal_update_device(→ api.db.Device | None)

Update an existing device in database.

Module Contents#

async device-manager.app.api.dal.dal_create_device(request: scanhub_libraries.models.DeviceCreationRequest, token_hash: str, salt: str) api.db.Device#

Add a new device to the database.

Arguments#

payload {BaseDevice} – Pydantic base model to create a new database entry

async device-manager.app.api.dal.dal_get_device(device_id: uuid.UUID) api.db.Device | None#

Fetch a device from database.

Arguments#

device_id {UUID} – Identifier of the device

Returns#

Device – Database orm model

async device-manager.app.api.dal.dal_get_all_devices() list[api.db.Device]#

Get a list of all existing devices.

Returns#

List[Device] – List of database orm models

async device-manager.app.api.dal.dal_delete_device(device_id: uuid.UUID) bool#

Delete a device by identifier.

Parameters#

device_id {UUID} – Identifier of the device to be deleted

Returns#

bool – Success of delete event

async device-manager.app.api.dal.dal_update_device(device_id: uuid.UUID, payload: dict) api.db.Device | None#

Update an existing device in database.

Parameters#

id {UUID} – Identifier of device payload {dict} – Dict with the fields to update.

Returns#

Device – Updated database orm model.