device_manager.api.device_endpoints#

Device API Endpoints.

This module defines the API routes and WebSocket endpoints for managing devices. It includes functionalities for: - CRUD operations on devices. - Device registration and status updates via WebSocket.

Copyright (C) 2023, BRAIN-LINK UG (haftungsbeschränkt). All Rights Reserved. SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-ScanHub-Commercial

Attributes#

Functions#

get_devices(]) → list[scanhub_libraries.models.DeviceOut])

Retrieve the list of registered devices.

get_device(current_user, device_id)

Retrieve a specific device.

create_device(], request)

Create device database entry.

delete_device(device_id, current_user)

Delete a device.

update_device_parameter(...)

Update acquisition/device parameter.

Module Contents#

device_manager.api.device_endpoints.oauth2_scheme#
device_manager.api.device_endpoints.LOG_CALL_DELIMITER = '-------------------------------------------------------------------------------'#
device_manager.api.device_endpoints.router#
async device_manager.api.device_endpoints.get_devices(current_user: Annotated[scanhub_libraries.models.User, Depends(get_current_user)]) → list[scanhub_libraries.models.DeviceOut]#

Retrieve the list of registered devices.

Returns:

List[Device]

Return type:

The list of registered devices.

async device_manager.api.device_endpoints.get_device(current_user: Annotated[scanhub_libraries.models.User, Depends(get_current_user)], device_id: uuid.UUID)#

Retrieve a specific device.

Parameters:

(str) (device_id)

Returns:

dict

Return type:

The response containing the information about the device

async device_manager.api.device_endpoints.create_device(current_user: Annotated[scanhub_libraries.models.User, Depends(get_current_user)], request: scanhub_libraries.models.DeviceCreationRequest) → fastapi.responses.StreamingResponse#

Create device database entry.

Only devices which are created by a user via this endpoint and have the device_id and device_token that result from this call configured correctly can later connect and register.

Parameters:

request – DeviceCreationRequest to create device in Scanhub. Further details of the device are later provided by the device itself.

Returns:

  • device_token – the token of the device which the user should copy manually to the configuration file of the device.

  • device_id – the id of the device, should be copied to the devices config file together with the device_token.

async device_manager.api.device_endpoints.delete_device(device_id: uuid.UUID, current_user: Annotated[scanhub_libraries.models.User, Depends(get_current_user)])#

Delete a device.

Parameters:

(str) (device_id)

Returns:

dict

Return type:

The response indicating the success or failure of the deletion.

async device_manager.api.device_endpoints.update_device_parameter(device_id: uuid.UUID | str, payload: dict, user: Annotated[scanhub_libraries.models.User, Depends(get_current_user)]) → scanhub_libraries.models.DeviceOut#

Update acquisition/device parameter.

Parameters:
  • device_id – Id of the device to be updated

  • payload – Parameter dictionary

Return type:

Parameter dictionary

Raises:

HTTPException – 404: Not found