def delete(cls): uuid = get_authorized_user_uuid() user = UserModel.find_by_uuid(uuid) if user is None: raise NotFoundException("User does not exist") user.delete_from_db() return '', 204
def get(cls, uuid): user_uuid = get_authorized_user_uuid() device: DeviceModel = DeviceModel.find_by_user_uuid_and_uuid( user_uuid, uuid) if device is None: raise NotFoundException('Device not found') return device
def delete(cls, device_id): user_uuid = get_authorized_user_uuid() device: DeviceModel = DeviceModel.find_by_user_uuid_and_device_id( user_uuid, device_id) if device is None: return '', 204 # we are not throwing error even though we didn't match the device_uuid device.delete_from_db() return '', 204
def delete(cls, uuid): user_uuid = get_authorized_user_uuid() device: DeviceModel = DeviceModel.find_by_user_uuid_and_uuid( user_uuid, uuid) if device is None: raise NotFoundException("Device not found") device.delete_from_db() return '', 204
def patch(cls): uuid = get_authorized_user_uuid() user = UserModel.find_by_uuid(uuid) if not user: raise NotFoundException("User does not exist") args = parse_user_update() user.update(**args) return user
def get(cls): uuid = get_authorized_user_uuid() user = UserModel.find_by_uuid(uuid) if not user: raise NotFoundException("User does not exist") output: List[SiteModel] = [] for site in user.sites: output.append(SiteModel.find_by_uuid(site.site_uuid)) return output
def post(cls): args = cls.parser.parse_args() uuid = str(shortuuid.uuid()) user_uuid = get_authorized_user_uuid() device = DeviceModel.find_by_user_uuid_and_device_id( user_uuid, args['device_id']) if device: return device device = DeviceModel(uuid=uuid, user_uuid=user_uuid, **args) device.save_to_db() return device
def patch(cls, uuid): parser = reqparse.RequestParser() parser.add_argument('device_id', type=str, required=False, store_missing=False) args = parser.parse_args() user_uuid = get_authorized_user_uuid() device: DeviceModel = DeviceModel.find_by_user_uuid_and_uuid( user_uuid, uuid) if device is None: raise NotFoundException("Device not found") device.update(**args) return device
def get(cls): device_info: Union[DeviceInfoModel, None] = get_device_info() if not device_info: logger.error('Please add device_info on Rubix Service') return uuid = get_authorized_user_uuid() user = UserModel.find_by_uuid(uuid) output: dict = {} for site in user.sites: output[site.site_uuid] = { 'layout_topic': f'{device_info.global_uuid}/{site.site_uuid}/layout', 'alert_topic': f'{device_info.global_uuid}/{site.site_uuid}/alerts' } return output
def get(cls): user_uuid = get_authorized_user_uuid() return DeviceModel.find_all_by_user_uuid(user_uuid=user_uuid)
def get(cls): username = get_authorized_username() uuid_ = get_authorized_user_uuid() return encode_jwt_token(uuid_, username)
def get(cls): uuid = get_authorized_user_uuid() user = UserModel.find_by_uuid(uuid) if not user: raise NotFoundException("User does not exist") return user