Example #1
0
 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
Example #2
0
 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
Example #3
0
 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
Example #4
0
 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
Example #5
0
 def get_user(cls, **kwargs) -> UserModel:
     return UserModel.find_by_uuid(kwargs.get('uuid'))
Example #6
0
 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